So ein paar Änderungen jaaaaaaa
This commit is contained in:
parent
678fd385f0
commit
035460735e
12
daten.pl
12
daten.pl
@ -63,18 +63,19 @@ init_feld1 :-
|
||||
|
||||
% Setzt das Spielfeld sowie die zugewiesenen einheiten zurück
|
||||
reset_game :-
|
||||
retractall( feld(_,_,_) ),
|
||||
retractall( einheit_active(_,_,_,_) ),
|
||||
retractall( player_tokens(_,_) ).
|
||||
abolish(feld/3),
|
||||
abolish(einheit_active/4),
|
||||
abolish(player_tokens/2).
|
||||
|
||||
|
||||
% Initialisiert die Einheiten für die jeweiligen Spieler
|
||||
init_player1(Player, Type1, Type2, Type3) :-
|
||||
init_player1(Type1, Type2, Type3) :-
|
||||
% Berechnet die zustehenden Tokens pro Runde für den Spieler
|
||||
einheit(Type1, _, Defense_Points1, _, Cost1),
|
||||
einheit(Type2, _, Defense_Points2, _, Cost2),
|
||||
einheit(Type3, _, Defense_Points3, _, Cost3),
|
||||
|
||||
Player = 1,
|
||||
player_tokens(Tokens),
|
||||
Cost is Tokens - (Cost1 + Cost2 + Cost3),
|
||||
assert( player_tokens(Player, Cost) ),
|
||||
@ -85,12 +86,13 @@ init_player1(Player, Type1, Type2, Type3) :-
|
||||
assert( einheit_active(Player,Type2,0,1,Defense_Points2) ),
|
||||
assert( einheit_active(Player,Type3,1,0,Defense_Points3) ).
|
||||
|
||||
init_player2(Player, Type1, Type2, Type3) :-
|
||||
init_player2(Type1, Type2, Type3) :-
|
||||
% Berechnet die zustehenden Tokens pro Runde für den Spieler
|
||||
einheit(Type1, _, Defense_Points1, _, Cost1),
|
||||
einheit(Type2, _, Defense_Points2, _, Cost2),
|
||||
einheit(Type3, _, Defense_Points3, _, Cost3),
|
||||
|
||||
Player = 2,
|
||||
player_tokens(Tokens),
|
||||
Cost is Tokens - (Cost1 + Cost2 + Cost3),
|
||||
assert( player_tokens(Player, Cost) ),
|
||||
|
85
debug.pl
Normal file
85
debug.pl
Normal file
@ -0,0 +1,85 @@
|
||||
% hier kommt so debug mäßiges zeugs hin
|
||||
|
||||
print_info(Type,X,Y,HP) :-
|
||||
write("-------"),nl,
|
||||
write("Type: "),
|
||||
write(Type), nl,
|
||||
|
||||
print_unit(X,Y), nl,
|
||||
|
||||
write("HP: "),
|
||||
write(HP),nl.
|
||||
|
||||
print_unit(X,Y) :-
|
||||
write("X/Y: "),
|
||||
write(X),
|
||||
write(":"),
|
||||
write(Y).
|
||||
|
||||
player_info :-
|
||||
write("## Player 1 ##"), nl,
|
||||
forall(einheit_active(1,Type,X,Y,HP),
|
||||
print_info(Type,X,Y,HP)),
|
||||
|
||||
write("-------"), nl,
|
||||
|
||||
write("Tokens: "),
|
||||
player_tokens(1,T1),
|
||||
write(T1), nl, nl,
|
||||
|
||||
write("=========="), nl, nl,
|
||||
|
||||
write("## Player 2 ##"), nl,
|
||||
forall(einheit_active(2,Type,X,Y,HP),
|
||||
print_info(Type,X,Y,HP)),
|
||||
|
||||
write("-------"), nl,
|
||||
|
||||
write("Tokens: "),
|
||||
player_tokens(1,T1),
|
||||
write(T1).
|
||||
|
||||
|
||||
quick_game :-
|
||||
% Ausgangszustand herstellen
|
||||
reset_game,
|
||||
init_feld1,
|
||||
init_player1(infantry,motorized,sniper),
|
||||
init_player2(tank,infantry,infantry),
|
||||
player_info, nl, nl,
|
||||
|
||||
write("==============="), nl,
|
||||
write("==============="), nl, nl, nl,
|
||||
|
||||
write("Player 1"), nl,
|
||||
einheit_move(0,0,1,1),
|
||||
write("0:0->1:1"), nl, nl,
|
||||
|
||||
change_player,
|
||||
|
||||
write("Player 2"), nl,
|
||||
einheit_move(3,4,3,1),
|
||||
write("3:4->3:1"), nl, nl,
|
||||
|
||||
change_player,
|
||||
|
||||
write("Player 1"), nl,
|
||||
einheit_attack(1,1,3,1),
|
||||
write("1:1-!->3:1"), nl, nl,
|
||||
|
||||
change_player,
|
||||
|
||||
write("Player 2"), nl,
|
||||
einheit_attack(3,1,1,1),
|
||||
write("3:1-!->1:1"), nl, nl,
|
||||
|
||||
change_player,
|
||||
|
||||
write("Player 1"), nl,
|
||||
einheit_attack(1,1,3,1),
|
||||
write("1:1-!->3:1"), nl, nl,
|
||||
|
||||
write("==============="), nl,
|
||||
write("==============="), nl, nl, nl,
|
||||
|
||||
player_info.
|
4
gui.pl
4
gui.pl
@ -3,8 +3,8 @@
|
||||
|
||||
% new(@specifier, dialog('windowname'))
|
||||
% send(@specifiert, append(text_item(name)))
|
||||
window(Name) :-
|
||||
new(D, dialog(Name)),
|
||||
window :-
|
||||
new(D, dialog("Game")),
|
||||
send(D, append, button(init, message(@prolog, init_feld1))),
|
||||
send(D, append, button(show3, message(@prolog, window3, 'Spielfeld'))),
|
||||
send(D, append, button(show2, message(@prolog, window2, 'Spielfeld'))),
|
||||
|
38
logik.pl
38
logik.pl
@ -14,6 +14,21 @@ change_player_to(Player) :-
|
||||
retract( current_player(_X) ),
|
||||
assert( current_player(Player) ).
|
||||
|
||||
% Verändern der Player Tokens hierüber
|
||||
change_player_tokens(TokensNew) :-
|
||||
TokensNew >= 0,
|
||||
current_player(Player),
|
||||
player_tokens(Player, Tokens)
|
||||
retract( player_tokens(Player, Tokens) ),
|
||||
assert( player_tokens(Player, TokensNew) ).
|
||||
|
||||
change_player_tokens_decrement :-
|
||||
current_player(Player),
|
||||
player_tokens(Player, Tokens),
|
||||
TokensDecrement is Tokens - 1,
|
||||
change_player_tokens(TokensDecrement).
|
||||
|
||||
|
||||
% Ein Spieler ist entweder current_player oder inactive_player
|
||||
% je nach dem ob dieser gerade am Zug ist oder nicht
|
||||
inactive_player(Player) :-
|
||||
@ -71,26 +86,33 @@ einheit_move(Xold, Yold, Xnew, Ynew) :-
|
||||
assert( einheit_active(Player, Type, Xnew, Ynew, Defense) ),
|
||||
|
||||
% Errechnen der verbleibenden Tokens
|
||||
retract( player_tokens(Player, Tokens) ),
|
||||
|
||||
betrag(Xold - Xnew, Xmove),
|
||||
betrag(Yold - Ynew, Ymove),
|
||||
|
||||
TokensNew is Tokens - Xmove - Ymove,
|
||||
TokensNew >= 0,
|
||||
|
||||
assert( player_tokens(Player, TokensNew) ).
|
||||
change_player_tokens(TokensNew).
|
||||
|
||||
|
||||
% Lässt zwei Einheiten gegeneinander Kämpfen
|
||||
% Die Einheit des aktuellen Spielers auf Xattack, Yattack
|
||||
% greift die Einheit des anderen auf Xdefend, Ydefend an
|
||||
einheit_attack(Xattack, Yattack, Xdefend, Ydefend) :-
|
||||
% Player token abziehen für den angriff-move
|
||||
% Falls nix übrig wird der angriff abgebrochen da false
|
||||
change_player_tokens_decrement,
|
||||
|
||||
% Info für kämpfende Einheiten abrufen
|
||||
current_player(Player),
|
||||
einheit_active(Player, TypeAttack, Xattack, Yattack, _),
|
||||
einheit_active(PlayerDefend, TypeDefend, Xdefend, Ydefend, HP),
|
||||
|
||||
% Info für Einheiten-Typen abrufen
|
||||
einheit(TypeAttack, AP, _, _, _),
|
||||
einheit(TypeDefend, _, _, MultDef, _),
|
||||
|
||||
% Den Kampf durchführen
|
||||
(
|
||||
(% Entweder die Einheit überlebt
|
||||
einheit_alive(AP, HP, HPnew, MultDef),
|
||||
@ -106,12 +128,6 @@ einheit_attack(Xattack, Yattack, Xdefend, Ydefend) :-
|
||||
),
|
||||
!.
|
||||
|
||||
% DEPRECATED, nur noch hier falls später für debug gebraucht
|
||||
% Prüft ob eine Einheit den Angriff überlebt und gibt die neue
|
||||
% Defense/HP aus falls dem so ist
|
||||
einheit_alive(AP, HP, HPnew) :-
|
||||
HPnew is HP - AP,
|
||||
HPnew > 0.
|
||||
|
||||
einheit_alive(AP, HP, HPnew, HPmult) :-
|
||||
% berechnen der differenz nach anwenden des multplikators
|
||||
@ -130,17 +146,21 @@ einheit_alive(AP, HP, HPnew, HPmult) :-
|
||||
einheit_delete(X, Y) :-
|
||||
retract( einheit_active(_, _, 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),
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user