From 448ecd81168816b51bf23219e8cc802ed4e2346e Mon Sep 17 00:00:00 2001 From: =?utf8?q?Benni=20B=C3=A4rmann?= Date: Fri, 19 Oct 2012 18:19:47 +0200 Subject: [PATCH] =?utf8?q?erste=20vorarbeiten=20f=C3=BCr=20JSON?= MIME-Version: 1.0 Content-Type: text/plain; charset=utf8 Content-Transfer-Encoding: 8bit --- INSTALL | 9 ++++++--- agrep | 4 ---- allgrep | 4 ++++ html/login.epl | 2 +- src/Aymargeddon.pm | 3 ++- src/FROGS/Command.pm | 25 +++++++++++++++++++++++++ withoutsqlgrep | 4 ++++ 7 files changed, 42 insertions(+), 9 deletions(-) delete mode 100755 agrep create mode 100755 allgrep create mode 100755 withoutsqlgrep diff --git a/INSTALL b/INSTALL index a861536..ccaac02 100644 --- a/INSTALL +++ b/INSTALL @@ -15,9 +15,12 @@ apt-get install libembperl-perl * folgende Perl-Module müssen vorhanden sein: - Date::Calc; - Mail::Mailer; - Data::Dumper; + Date::Calc + Mail::Mailer + Data::Dumper + JSON + + gibts alle auch als Debian-Pakete. * MySQL als DBMS diff --git a/agrep b/agrep deleted file mode 100755 index 1229a61..0000000 --- a/agrep +++ /dev/null @@ -1,4 +0,0 @@ -#!/bin/sh - -grep $1 src/*.pl src/*.pm src/FROGS/*.pm html/*.epl var/*.sql - diff --git a/allgrep b/allgrep new file mode 100755 index 0000000..1229a61 --- /dev/null +++ b/allgrep @@ -0,0 +1,4 @@ +#!/bin/sh + +grep $1 src/*.pl src/*.pm src/FROGS/*.pm html/*.epl var/*.sql + diff --git a/html/login.epl b/html/login.epl index 55066e2..c4602cd 100644 --- a/html/login.epl +++ b/html/login.epl @@ -33,7 +33,7 @@ [- my $lang = 'DE'; # TODO: use DEFAULT_LANGUAGE from config - # TODO BUG: default-language looks to be allways EN here... + # TODO BUG: default-language seems to be allways EN here... $lang = $udat{-lang} if exists $udat{-lang}; $new_passwd = $db->new_account($fdat{'newlogin'}, diff --git a/src/Aymargeddon.pm b/src/Aymargeddon.pm index 7b93246..e4fa7d1 100644 --- a/src/Aymargeddon.pm +++ b/src/Aymargeddon.pm @@ -38,7 +38,7 @@ use Data::Dumper; @Aymargeddon::ISA = qw(Game); sub new{ - my ($class,$game,$user,$db,$lang) = @_; + my ($class,$game,$user,$db,$lang) = @_; #TODO: $lang not used here? my $self = Game->new($game,$user,$db); @@ -49,6 +49,7 @@ sub get_map{ my $self = shift; unless (exists $self->{-map}){ + # TODO: HOME dupplication correct? $self->{-map} = $self->read_map("TERRAIN,HOME,OCCUPANT,TEMPLE,PLAGUE,HOME"); } return $self->{-map}; diff --git a/src/FROGS/Command.pm b/src/FROGS/Command.pm index 056f9ec..3507535 100644 --- a/src/FROGS/Command.pm +++ b/src/FROGS/Command.pm @@ -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($aff); + +} + sub setDuration { # sets the duration of the command in units. Sheduler will schedule # the Phase 2 then for gametime+units*pace(game). diff --git a/withoutsqlgrep b/withoutsqlgrep new file mode 100755 index 0000000..a6af5fe --- /dev/null +++ b/withoutsqlgrep @@ -0,0 +1,4 @@ +#!/bin/sh + +grep $1 src/*.pl src/*.pm src/FROGS/*.pm html/*.epl + -- 2.1.4