From e8c9720041984e8ec6cf9d3f742e9a66ef4b8031 Mon Sep 17 00:00:00 2001 From: xxsoca Date: Sun, 4 Jun 2023 21:53:49 +0200 Subject: [PATCH] first iteration of save_ap and calc_ap --- daten.pl | 2 ++ logik.pl | 24 +++++++++++++++++++++++- 2 files changed, 25 insertions(+), 1 deletion(-) diff --git a/daten.pl b/daten.pl index ca500ac..4d2f639 100644 --- a/daten.pl +++ b/daten.pl @@ -24,6 +24,8 @@ player(2). % Die Anzahl an tokens die pro Runde an die Spieler verteilt wird player_tokens(10). +% Der Turncounter +turn_counter(1). % Erschafft ein festes Spielfeld init_feld1 :- diff --git a/logik.pl b/logik.pl index f3cccd8..5d483dc 100644 --- a/logik.pl +++ b/logik.pl @@ -4,6 +4,11 @@ % nicht bei jedem Aufruf angegeben werden muss :- assert( current_player(1) ). % das muss so weil sonst err +% Damit vorherige action points (=0) auch in der ersten Runde exisiteren, sonst err +:- + assert( turn_action_points(1, 0) ), + assert( turn_action_points(2, 0) ). + % Aktualisieren des aktuellen Spielers geht hiermit change_player_to(Player) :- retract( current_player(_X) ), @@ -29,7 +34,7 @@ change_player :- player_turn(Player) :- % calculate action points - calc_action_points(Player, _Turncounter), + calc_action_points(Player), % further logic @@ -116,4 +121,21 @@ einheit_delete(X, Y) :- get_color_of_fieldType(FieldTypeInt, Color) :- feldType(_, FieldTypeInt, Color). + +save_action_points(Player) :- + turn_action_points(Player, Ap), + retract( turn_action_points(Player, _) ), + assert( turn_action_points(Player, Ap) ). + +calc_action_points(Player) :- + % get initial AP at start of game + player_tokens(Player, FirstRound), + % get leftover action points from turn before + turn_action_points(Player, RoundBefore), + + % calculate for new turn + AP is RoundBefore + FirstRound, + + retract( turn_action_points(Player, _) ), + assert( turn_action_points(Player, AP)). \ No newline at end of file