Urbley Posted January 14, 2009 Share Posted January 14, 2009 This is really only a general cry for help. I just need some direction in a specific area. Up until now (Over the past 4 years or so) I have only ever really used php for intermediate database manipulation with MySQL. I recently started a new job and as such am required to extend my knowledge of PHP so have assigned myself a project as such to help with this. I'm sure there are a few people that will have a giggle here but anyways... I play an online browser based game called Ogame which is a space simulation game consisting of colonising and developing planets throughout a universe consisting of 9 galaxies and each galaxy has 499 solar systems and each solar system has 15 planet slots which you can colonise. One aspect of the game is to attack another players planet to steal their resources and destroy their ships and defense. Then we proceed to a forum where we post our combat reports (cr's) and gloat. The raw text for a combat report looks like this (I have replaced peoples names with XXX); At 01-14 11:45:23 the following fleets met in battle:: Attacker XXX ([2:62:8]) Weapons: 140% Shields: 140% Armour: 150% Type Bomber Dest. Total 1.735 350 Weapons 2.400 4.800 Shields 1.200 1.200 Armour 18.750 27.500 Defender XXX ([2:60:4]) Weapons: 120% Shields: 110% Armour: 120% Type S.Cargo L.Cargo L.Fighter Cruiser Battleship Sol. Sat Dest. Battlecr. R.Launcher L.Laser H.Laser Gauss Ion C. Plasma S.Dome L.Dome Total 2 140 375 9 99 1 13 31 2.439 1.039 94 128 45 49 1 1 Weapons 11 11 110 880 2.200 2 4.400 1.540 176 220 550 2.420 330 6.600 2 2 Shields 21 53 21 105 420 2 1.050 840 42 53 210 420 1.050 630 4.200 21.000 Armour 880 2.640 880 5.940 13.200 440 24.200 15.400 440 440 1.760 7.700 1.760 22.000 4.400 22.000 The attacking fleet fires 8.060 times with a total firepower of 20.385.600 at the defender. The defending shields absorb 352.126 damage In total, the defending fleet fires 4.466 times with a total firepower of 1.731.032 at the attacker. The attackers shields absorb 1.023.073 damage Attacker XXX ([2:62:8]) Type Bomber Dest. Total 1.726 350 Weapons 2.400 4.800 Shields 1.200 1.200 Armour 18.750 27.500 Defender XXX ([2:60:4]) Type S.Cargo L.Cargo L.Fighter Cruiser Battleship Dest. Battlecr. R.Launcher L.Laser H.Laser Gauss Ion C. Plasma S.Dome L.Dome Total 1 26 69 2 68 13 26 402 165 9 90 10 46 1 1 Weapons 11 11 110 880 2.200 4.400 1.540 176 220 550 2.420 330 6.600 2 2 Shields 21 53 21 105 420 1.050 840 42 53 210 420 1.050 630 4.200 21.000 Armour 880 2.640 880 5.940 13.200 24.200 15.400 440 440 1.760 7.700 1.760 22.000 4.400 22.000 The attacking fleet fires 4.626 times with a total firepower of 12.146.400 at the defender. The defending shields absorb 182.441 damage In total, the defending fleet fires 929 times with a total firepower of 893.193 at the attacker. The attackers shields absorb 392.515 damage Attacker XXX ([2:62:8]) Type Bomber Dest. Total 1.723 350 Weapons 2.400 4.800 Shields 1.200 1.200 Armour 18.750 27.500 Defender XXX ([2:60:4]) Type L.Fighter Battleship Dest. Battlecr. R.Launcher L.Laser Gauss Plasma L.Dome Total 1 4 4 3 4 1 5 13 1 Weapons 110 2.200 4.400 1.540 176 220 2.420 6.600 2 Shields 21 420 1.050 840 42 53 420 630 21.000 Armour 880 13.200 24.200 15.400 440 440 7.700 22.000 22.000 The attacking fleet fires 2.339 times with a total firepower of 6.492.000 at the defender. The defending shields absorb 40.742 damage In total, the defending fleet fires 36 times with a total firepower of 129.956 at the attacker. The attackers shields absorb 34.664 damage Attacker XXX ([2:62:8]) Type Bomber Dest. Total 1.722 350 Weapons 2.400 4.800 Shields 1.200 1.200 Armour 18.750 27.500 Defender XXX ([2:60:4]) destroyed The attacker has won the battle! He captured 675.444 metal, 192.759 crystal, and 537.684 deuterium The attacker lost a total of 975.000 units. The defender lost a total of 30.541.000 units. At these space coordinates now float 2.689.200 metal and 1.495.200 crystal. The chance for a moon to be created is 20 % There are currently CR converters out there which will take this information in a textarea and format the report for usage on various forums to make it more presentable. An example of one such converter would be, http://crconv.vafan.se/ select english i.e. ogame.org and click go. You would then take your raw data and paste it into the CombatReport: textarea on the lower left side and click convert after choosing various options about presentation etc and in the Result: textarea you would receive a formatted report which would be coloured etc for usage on the forum. [center] [color=#00DDFF][b]The following fleets met in battle:[/b][/color] [color=#B9B9B9]Attacker:[/color] [b][color=#FF0000]XXX[/color][/b] [color=#FF0000]Bomber[/color][color=#FF0000]...[/color][color=#FF0000]1.735[/color] [color=#FF0000]Dest.[/color][color=#FF0000]...[/color][color=#FF0000]350[/color] [color=#B9B9B9]Defender:[/color] [b][color=#0099FF]XXX[/color][/b] [color=#FF0000]S.Cargo[/color][color=#FF0000]...[/color][color=#FF0000]2[/color] [color=#FF0000]L.Cargo[/color][color=#FF0000]...[/color][color=#FF0000]140[/color] [color=#FF0000]L.Fighter[/color][color=#FF0000]...[/color][color=#FF0000]375[/color] [color=#FF0000]Cruiser[/color][color=#FF0000]...[/color][color=#FF0000]9[/color] [color=#FF0000]Battleship[/color][color=#FF0000]...[/color][color=#FF0000]99[/color] [color=#FF0000]Sol. Sat[/color][color=#FF0000]...[/color][color=#FF0000]1[/color] [color=#FF0000]Dest.[/color][color=#FF0000]...[/color][color=#FF0000]13[/color] [color=#FF0000]Battlecr.[/color][color=#FF0000]...[/color][color=#FF0000]31[/color] [color=#0099FF]R.Launcher[/color][color=#0099FF]...[/color][color=#0099FF]2.439[/color] [color=#0099FF]L.Laser[/color][color=#0099FF]...[/color][color=#0099FF]1.039[/color] [color=#0099FF]H.Laser[/color][color=#0099FF]...[/color][color=#0099FF]94[/color] [color=#0099FF]Gauss[/color][color=#0099FF]...[/color][color=#0099FF]128[/color] [color=#0099FF]Ion C.[/color][color=#0099FF]...[/color][color=#0099FF]45[/color] [color=#0099FF]Plasma[/color][color=#0099FF]...[/color][color=#0099FF]49[/color] [color=#0099FF]S.Dome[/color][color=#0099FF]...[/color][color=#0099FF]1[/color] [color=#0099FF]L.Dome[/color][color=#0099FF]...[/color][color=#0099FF]1[/color] [b][color=#FF0000] -- After battle -- [/color][/b] [color=#B9B9B9]Attacker:[/color] [b][color=#FF0000]XXX[/color][/b] [color=#FF0000]Bomber[/color][color=#FF0000]...[/color][color=#FF0000]1.722[/color][color=#8000FF] ( lost: 13 )[/color] [color=#FF0000]Dest.[/color][color=#FF0000]...[/color][color=#FF0000]350[/color][color=#8000FF] ( lost: 0 )[/color] [color=#B9B9B9]Defender:[/color] [b][color=#0099FF]XXX[/color][/b] [color=#B9B9B9]Destroyed[/color] [b][color=#00DDFF]The attacker has won the battle![/color][/b] [color=#B9B9B9] He [/color] [color=#B9B9B9] captured [/color] [color=#8000FF][b]675.444[/b][/color][color=#B9B9B9] metal [/color] [color=#8000FF][b]192.759[/b][/color][color=#B9B9B9] crystal [/color] [color=#B9B9B9] and [/color] [color=#8000FF][b]537.684[/b][/color][color=#B9B9B9] deuterium [/color] [color=#B9B9B9] The [/color] [color=#B9B9B9] attacker [/color] [color=#B9B9B9] lost [/color] [color=#B9B9B9] a [/color] [color=#B9B9B9] total [/color] [color=#B9B9B9] of [/color] [color=#8000FF][b]975.000[/b][/color][color=#B9B9B9] units. [/color] [color=#B9B9B9] The [/color] [color=#B9B9B9] defender [/color] [color=#B9B9B9] lost [/color] [color=#B9B9B9] a [/color] [color=#B9B9B9] total [/color] [color=#B9B9B9] of [/color] [color=#8000FF][b]30.541.000[/b][/color][color=#B9B9B9] units. [/color] [color=#B9B9B9] At [/color] [color=#B9B9B9] these [/color] [color=#B9B9B9] space [/color] [color=#B9B9B9] coordinates [/color] [color=#B9B9B9] now [/color] [color=#B9B9B9] float [/color] [color=#8000FF][b]2.689.200[/b][/color][color=#B9B9B9] metal [/color] [color=#B9B9B9] and [/color] [color=#8000FF][b]1.495.200[/b][/color][color=#B9B9B9] crystal. [/color] [color=#B9B9B9] The [/color] [color=#B9B9B9] chance [/color] [color=#B9B9B9] for [/color] [color=#B9B9B9] a [/color] [color=#B9B9B9] moon [/color] [color=#B9B9B9] to [/color] [color=#B9B9B9] be [/color] [color=#B9B9B9] created [/color] [color=#B9B9B9] is [/color] [color=#8000FF][b]20[/b][/color][color=#B9B9B9] % [/color] [b][color=#00DDFF]Battle Result[/color][/b] [color=#B9B9B9](Assuming the attacker got the debris..)[/color] [color=#B9B9B9]Attacker gain:[/color] [color=#8000FF][b]4.615.287[/b][/color] [color=#B9B9B9]Defender lost:[/color] [color=#8000FF][b]30.541.000[/b][/color] [color=#B9B9B9][b]Total Damage:[/b][/color] [color=#8000FF][b]31.516.000[/b][/color] [size=10] [url=http://crconv.vafan.se][color=#7B90B8]Converted with Invader Skodge's CR Converter 3.5[/color][/url][/size] [/center] You can now see that the raw code has been sorted and arranged as such to make it more visually appealing on a forum. Simple things like stripping out unnecessary words and information. Only showing the first and last rounds in the battle etc. I am not looking to know in specific detail how this works and perhaps this post is even in the wrong forum but what I was hoping was to maybe strike up a discussion about the various methods used in such a process so that I might be able to head off on my own and be able to learn how such a process is formed. Any ideas would be absolutely amazing. You can see the finished article after using such a converter at http://board.ogame.org and then scrolling to any universe and looking in the HoF (hall of fame) section. Basically string manipulation and this kind of process in PHP has always intrigued me but I have never known where to start and I am hoping that there are many people out there like me who would be willing to have a discussion about this topic with an aim to figuring out some of the functions involved. If this indeed in the wrong forum, my apologies. P.S. do yourself a favour and don't become addicted to the game. Thanks. Steve Quote Link to comment https://forums.phpfreaks.com/topic/140821-general-craving-for-php-knowledge/ Share on other sites More sharing options...
Urbley Posted January 14, 2009 Author Share Posted January 14, 2009 Sorry and thanks Quote Link to comment https://forums.phpfreaks.com/topic/140821-general-craving-for-php-knowledge/#findComment-737067 Share on other sites More sharing options...
xtopolis Posted January 14, 2009 Share Posted January 14, 2009 Too much information. It looks like a custom regexp parser. It uses regular expressions to to search out certain strings and then move (rather cut/replace) them with appropriate color tags, etc. You can read up on regular expressions here: http://www.phpfreaks.com/tutorial/regular-expressions-part1---basic-syntax Otherwise you'll probably need more specific questions for better assistance. Quote Link to comment https://forums.phpfreaks.com/topic/140821-general-craving-for-php-knowledge/#findComment-737216 Share on other sites More sharing options...
Urbley Posted January 15, 2009 Author Share Posted January 15, 2009 Thx xtopolis. I wasn't really asking questions as such. Just wondered if anyone had any input on the theory around these converters as a whole. I'm trying to search out people who are curious about the whole business of string manipulation and now also regexp I understand PHP and MySQL very well but when it comes to this string stuff I have no idea. I would love to change that. Quote Link to comment https://forums.phpfreaks.com/topic/140821-general-craving-for-php-knowledge/#findComment-737370 Share on other sites More sharing options...
xtopolis Posted January 15, 2009 Share Posted January 15, 2009 Well, what do you want to know about it? Perhaps if you email the creator, he might also give you some tips etc? I do not understand your I'm trying to search out people who are curious about the whole business of string manipulation and now also regexp I understand PHP and MySQL very well but when it comes to this string stuff I have no idea. thing... ... Something you could do is try to recreate what his parser does a step at a time on your own. That way you'd be learning as well as have motivation because it's something you enjoy and spend time on (your game). Quote Link to comment https://forums.phpfreaks.com/topic/140821-general-craving-for-php-knowledge/#findComment-737384 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.