Forum

[en] event format
RiDDi
07.12.09 - 12:53
What is the format of events returned by the method Control->events?
The doc of Control says that it returns an array of hash-references, and that each of these hashes have a key 'turn'. After that it gets rather ambiguous.
Darko
07.12.09 - 16:16
True. I will add this to the manual tomorrow.
Darko
08.12.09 - 11:12
Correcting myself: all information is in the API documentation of the Control class:
http://cosair.org/doc/ai_doc.cgi?browse=1&class=Control#events__

In case you need anything of general interest from that list, I could add a method for that.
RiDDi
08.12.09 - 17:55
From what we've read in the doc, we're not sure what the method returns. It could either be
1) the hashes contain a key 'type' that implies what other keys are stored in the hash
or
2) The event-hashes contain have a key 'colonisation', 'attack_failed', 'attack_successful' or 'extermination' that points to another hash

In particular we're interested in successful attacks against our nation and our nation's colonisations.
Once we know the exact format of events these should be easy enough to extract.
Darko
09.12.09 - 12:00
Option 1 is the right one (and the easiest one I think).
I should obviously be more precise here.

To get your own colonisations:

grep {
$_->{type} eq 'colonisation'
&& $_->{nation_one_id} == $self->control->own_nation->id
} $self->control->events;
Back to Topic Overview

Back to Main Page