some bugs with json fixed
[aymargeddon/current.git] / src / FROGS / Command.pm
index 9d702e0..58bf52a 100644 (file)
@@ -3,7 +3,7 @@
 #   Copyright (c) 2003-2012 Aymargeddon Development Team
 #
 #   This file is part of "Last days of Aymargeddon" - a massive multi player
-#   onine game of strategy     
+#   online game of strategy    
 #   
 #        This program is free software: you can redistribute it and/or modify
 #       it under the terms of the GNU Affero General Public License as
@@ -183,6 +183,31 @@ sub done {
   # TODO?: send messages
 }
 
+# returns a hash with all data wich is affected from the command
+sub affected{
+    my $self = shift;
+    
+    my $aff = $self->{-affected};
+    for my $field (@{$aff->{-fields}}){
+       #TODO? build field data         
+    }
+    
+    return $aff;
+}
+
+# returns a JSON-Object with all new infos which should displayd from client
+sub first_phase_ajax{
+    my $self = shift;
+    
+    my $ret = $self->first_phase();
+    #TODO: which part of the logic in execute() is needed here?
+    
+    my $aff = $self->affected();
+    use JSON;
+    return encode_json($aff);
+    
+}
+
 sub setDuration {
 # sets the duration of the command in units. Sheduler will schedule
 # the Phase 2 then for gametime+units*pace(game).