|
Post by Old Shendemiar on Aug 16, 2005 21:25:11 GMT
Bah, problems! Jst when I thought I had it sussed, thanks to Roberts help! If you cut and paste direct from IK, it puts tabs in between Gold Mine and Level, for all the items I want to pick out! Is there a way of telling my code to either ignore tabs or put them into the string I am searching for? If I just put a tab into the code does that work? Heck, I'll try it and see! Second problem is with amounts for Stonethrowers etc, if I say allow 4 or 5 chars for these, you might find the attacking force is included, can I tell the code to stop when it comes to a space in terms of length of $needle? In other words $needle should be trimmed of anything after the first space? Again I think this will be possible and in fact I might have some code from Pitstop which did that, amazing how things come back to you when you type, so ignore this, me thinking out loud! Pitstop was useful for something after all! Finally island coordinates, you might get the wrong coordinates as it will read the spying persons coordinates first, I suppose I can loop thought the code twice to get the second coordinates which I need? Or maybe mask it, if the coordinate matches what you got first time ignore it or something. Sorry to bug you with stupid questions! Before inserting data to database, or after retrieving it from there, you could have php remove all tabs or replace them with spaces. Read manual for string replacement funtions. Tab is a special character marked \t or something like that.. So a string "Koira kana \t Sika Lehmä" would have tab break there. Yes you propably need occasionally to edit the $ansver bit further. IT is possible to return everything from a string until some character occures. I dont remeber the actual funtion, but check the string functions list with care. ( fi2.php.net/strings) OR code new fuction like the one you allready have, to return something from a string before some special character. You could aso send it again back to the extractfromspyreport with different parameters. If you could paste the original string, the output you get, and explain what you want to extract from it, i could code it. IT's also possible to $answer = explode($string,"/") to an array of parts. IF original is " 12 / 3453" then answer[0] = " 12" and answer[1]= " 3453" and so on. I cant resolve the coordinate issue without seeing an actual spyreport, but i would imagine it says something like spyer or target that can be used as a key to determine whoch coords are in question.
|
|
SkulkrinBait
Morkin Admin
Haxx0rs == Suxx0rs! v4
Posts: 6,680
|
Post by SkulkrinBait on Aug 16, 2005 21:27:46 GMT
The coordinates aren't an issue, I managed to get those OK, so far, not tested with weird coordinates yet though! Thanks, looks like I am going to be busy, just found another problem. What are your thoughts on this, Gold, Lumber and Stone appear twice, once in Gold Mine etc and once as just resource types, how can I make it get both values I need. Don't spend much time helping me as I really should do my own work! But thanks again anyway!
|
|
|
Post by Old Shendemiar on Aug 16, 2005 21:41:05 GMT
The coordinates aren't an issue, I managed to get those OK, so far, not tested with weird coordinates yet though! Thanks, looks like I am going to be busy, just found another problem. What are your thoughts on this, Gold, Lumber and Stone appear twice, once in Gold Mine etc and once as just resource types, how can I make it get both values I need. Don't spend much time helping me as I really should do my own work! But thanks again anyway! Dont worry about my time, i wouldnt write if i didnt want to About the coords, thou you have an ansver allready: It says something like "spy report" in the beginning. You can check if it says so, and have phph delete some amount of chars from the begininning of the report, if it does. That way you would delete attackers details if they are pasted in the fisrt place (You also need to remember that someone could paste only a part of spy report ;D) Then the duplicates: Whit "gold mine" there should be no prob, but only "gold" returns wrong part. You could awoid this by splitting the initial report into parts in the first place after retrieving it from the database. $initialreport = from the database $buildings = part of $initialreport between words "buildings" and "research" $research = part between "research" and "resources" $resources = the rest. and then extracting the wanted data from these. There are many ways to do it, using strpos, strlen and substr functions, or explode etc.
|
|
SkulkrinBait
Morkin Admin
Haxx0rs == Suxx0rs! v4
Posts: 6,680
|
Post by SkulkrinBait on Aug 16, 2005 22:21:18 GMT
Yeah, explode rings a bell I think I used that in Pitstop to extract first name and last name from users by splitting the variable before and after the space.
|
|
SkulkrinBait
Morkin Admin
Haxx0rs == Suxx0rs! v4
Posts: 6,680
|
Post by SkulkrinBait on Aug 16, 2005 22:52:38 GMT
Woohooo!!!! I got it working using explode, basing the split on what comes after the word Resources! Thanks once again, a large chocolate rat for you Robert!
|
|
|
Post by Old Shendemiar on Aug 16, 2005 23:12:53 GMT
Woohooo!!!! I got it working using explode, basing the split on what comes after the word Resources! Thanks once again, a large chocolate rat for you Robert! Yummy! Maybe i should send my mumbojumbo about the dark athletees to Carol as compensation...
|
|
|
Post by Old Shendemiar on Aug 16, 2005 23:17:02 GMT
It might be good idea to show the original anyway. Some reports may be incomplete or erroneous, with special characters or nto spy reports at all, but other info about those coords.
(Put also some sample coordinates visible so people can test the utility, later maybe a list of coordinates in the database)
|
|
SkulkrinBait
Morkin Admin
Haxx0rs == Suxx0rs! v4
Posts: 6,680
|
Post by SkulkrinBait on Aug 16, 2005 23:22:05 GMT
I don't understand? You mean keep the whole thing pasted in as a var too? I am doing that anyway for posterity.
One last thing, for now!
I can't get rid of the tabs, this isn't working:
str_replace("\t", "", $description);
Any ideas?
|
|
SkulkrinBait
Morkin Admin
Haxx0rs == Suxx0rs! v4
Posts: 6,680
|
Post by SkulkrinBait on Aug 16, 2005 23:30:19 GMT
Are they really tabs I wonder?
|
|
SkulkrinBait
Morkin Admin
Haxx0rs == Suxx0rs! v4
Posts: 6,680
|
Post by SkulkrinBait on Aug 16, 2005 23:37:21 GMT
Weird, this doesn't do anything, Robert!!!!!!!!
str_replace("s", " ", $description);
|
|
Freiegeister
Morkin Member
'Blasphemy is a victimless crime' - Dawkins
Posts: 1,126
|
Post by Freiegeister on Aug 16, 2005 23:42:29 GMT
It might be good idea to show the original anyway. Some reports may be incomplete or erroneous, with special characters or nto spy reports at all, but other info about those coords. (Put also some sample coordinates visible so people can test the utility, later maybe a list of coordinates in the database) There are really only two reports: Espionage and Attack. What if you could just copy and paste the whole report and the utility will parse it extracting the details? When a island is viewed you could calculate the maximum resources based on the known production rates and the date. An Espionage report would replace any existing data, while an attack report would recalculate the resources based on what is expected to be there or to the minimum when the resources taken are less than the ship capacity. A notes field would be helpful along with a history of attacks. Am I asking too much?
|
|
|
Post by Old Shendemiar on Aug 17, 2005 0:37:53 GMT
It might be good idea to show the original anyway. Some reports may be incomplete or erroneous, with special characters or nto spy reports at all, but other info about those coords. (Put also some sample coordinates visible so people can test the utility, later maybe a list of coordinates in the database) There are really only two reports: Espionage and Attack. What if you could just copy and paste the whole report and the utility will parse it extracting the details? Yes, but one could also add text of one's own. Like "Keep out, this is a trap!" heh heh It's meant to be that one could paste the whole report and the utility parses the data.
|
|
Freiegeister
Morkin Member
'Blasphemy is a victimless crime' - Dawkins
Posts: 1,126
|
Post by Freiegeister on Aug 17, 2005 1:31:55 GMT
There are really only two reports: Espionage and Attack. What if you could just copy and paste the whole report and the utility will parse it extracting the details? Yes, but one could also add text of one's own. Like "Keep out, this is a trap!" heh heh It's meant to be that one could paste the whole report and the utility parses the data. Cool
|
|
SkulkrinBait
Morkin Admin
Haxx0rs == Suxx0rs! v4
Posts: 6,680
|
Post by SkulkrinBait on Aug 17, 2005 5:49:29 GMT
I think I sorted it so it now removes tabs, I made a really dumb mistake which I only realised after I went to bed, must have been too late for my brain!
I can easily add a section for notes and comments if people want it, I could also work out resource levels but I'm not sure how useful that would be as others might raid, resources are used up etc. But if people want it let me know.
In fact the utility is now finished (v1.0) and is ready for alpha testing, just needs tidying up a bit.
|
|
Freiegeister
Morkin Member
'Blasphemy is a victimless crime' - Dawkins
Posts: 1,126
|
Post by Freiegeister on Aug 17, 2005 6:03:32 GMT
I think I sorted it so it now removes tabs, I made a really dumb mistake which I only realised after I went to bed, must have been too late for my brain! I can easily add a section for notes and comments if people want it, I could also work out resource levels but I'm not sure how useful that would be as others might raid, resources are used up etc. But if people want it let me know. In fact the utility is now finished (v1.0) and is ready for alpha testing, just needs tidying up a bit. Cool! I have a spreadsheet full of reports to upload.
|
|