2023-05-22 14:03:51 +02:00
|
|
|
:- use_module(library(pce)).
|
|
|
|
|
2023-06-04 21:20:14 +02:00
|
|
|
numCols(5).
|
|
|
|
numRows(5).
|
|
|
|
|
2023-05-22 14:03:51 +02:00
|
|
|
% Später für die Ausgabe des Types vom Terrain an den Nutzer
|
2023-06-04 19:24:58 +02:00
|
|
|
feldType(grass, 1, green).
|
|
|
|
feldType(mountain, 2, grey).
|
|
|
|
feldType(water, 3, blue).
|
2023-05-22 14:03:51 +02:00
|
|
|
|
2023-06-25 10:03:20 +02:00
|
|
|
% Terrain-Multiplier für Attack
|
|
|
|
% feldMultiplier(von, nach, mult)
|
|
|
|
feldMultiplier(1, 1, 1.0).
|
|
|
|
feldMultiplier(1, 2, 0.5).
|
|
|
|
feldMultiplier(1, 3, 1.5).
|
|
|
|
|
|
|
|
feldMultiplier(2, 1, 1.5).
|
|
|
|
feldMultiplier(2, 2, 1.0).
|
|
|
|
feldMultiplier(2, 3, 0.5).
|
|
|
|
|
|
|
|
feldMultiplier(3, 1, 1.5).
|
|
|
|
feldMultiplier(3, 2, 0.5).
|
|
|
|
feldMultiplier(3, 3, 1.0).
|
|
|
|
|
2023-06-21 14:31:36 +02:00
|
|
|
% einheit(type, attack, defense, action multiplier, upkeep, symbol)
|
2023-05-22 14:37:08 +02:00
|
|
|
% der multiplier ist der angewandte faktor für boni/mali
|
2023-06-21 14:31:36 +02:00
|
|
|
einheit(infantry, 2, 2, 2, 1, i).
|
2023-06-23 18:04:29 +02:00
|
|
|
einheit(robot, 3, 1, 3, 1, r).
|
2023-06-21 14:31:36 +02:00
|
|
|
einheit(motorized, 4, 3, 2, 2, m).
|
2023-06-25 10:15:23 +02:00
|
|
|
einheit(tank, 5, 5, 3, 3, t).
|
2023-05-22 14:03:51 +02:00
|
|
|
|
|
|
|
% Startpositionen der Spieler mit jeweils -1 auf die coords
|
|
|
|
% Damit ist die init_player universell
|
2023-05-30 18:34:43 +02:00
|
|
|
% playerStart(Player, X, Y)
|
2023-05-30 22:53:30 +02:00
|
|
|
player(1).
|
|
|
|
player(2).
|
2023-05-22 14:03:51 +02:00
|
|
|
|
2023-05-22 15:10:00 +02:00
|
|
|
% Die Anzahl an tokens die pro Runde an die Spieler verteilt wird
|
2023-06-23 17:53:45 +02:00
|
|
|
player_tokens(8).
|
2023-05-22 15:10:00 +02:00
|
|
|
|
2023-06-04 21:53:49 +02:00
|
|
|
% Der Turncounter
|
|
|
|
turn_counter(1).
|
2023-05-22 14:03:51 +02:00
|
|
|
|
2023-06-23 14:21:47 +02:00
|
|
|
% Textfarbe Spieler
|
|
|
|
player_color(1, black).
|
|
|
|
player_color(2, white).
|
|
|
|
|
2023-05-22 14:03:51 +02:00
|
|
|
% Erschafft ein festes Spielfeld
|
|
|
|
init_feld1 :-
|
|
|
|
% feld(X, Y, Type)
|
2023-06-25 13:23:03 +02:00
|
|
|
assert( feld(0, 0, 2) ),
|
2023-05-22 14:03:51 +02:00
|
|
|
assert( feld(0, 1, 2) ),
|
|
|
|
assert( feld(0, 2, 1) ),
|
|
|
|
assert( feld(0, 3, 1) ),
|
|
|
|
assert( feld(0, 4, 1) ),
|
|
|
|
|
|
|
|
assert( feld(1, 0, 1) ),
|
|
|
|
assert( feld(1, 1, 1) ),
|
|
|
|
assert( feld(1, 2, 1) ),
|
2023-06-25 13:23:03 +02:00
|
|
|
assert( feld(1, 3, 3) ),
|
|
|
|
assert( feld(1, 4, 3) ),
|
2023-05-22 14:03:51 +02:00
|
|
|
|
|
|
|
assert( feld(2, 0, 1) ),
|
2023-06-25 13:23:03 +02:00
|
|
|
assert( feld(2, 1, 2) ),
|
2023-06-04 21:20:14 +02:00
|
|
|
assert( feld(2, 2, 3) ),
|
|
|
|
assert( feld(2, 3, 3) ),
|
2023-05-22 14:03:51 +02:00
|
|
|
assert( feld(2, 4, 1) ),
|
|
|
|
|
|
|
|
assert( feld(3, 0, 1) ),
|
2023-06-25 13:23:03 +02:00
|
|
|
assert( feld(3, 1, 3) ),
|
|
|
|
assert( feld(3, 2, 2) ),
|
|
|
|
assert( feld(3, 3, 2) ),
|
2023-05-22 14:03:51 +02:00
|
|
|
assert( feld(3, 4, 1) ),
|
|
|
|
|
2023-06-25 13:23:03 +02:00
|
|
|
assert( feld(4, 0, 3) ),
|
|
|
|
assert( feld(4, 1, 3) ),
|
2023-05-22 14:03:51 +02:00
|
|
|
assert( feld(4, 2, 1) ),
|
|
|
|
assert( feld(4, 3, 1) ),
|
2023-06-25 13:23:03 +02:00
|
|
|
assert( feld(4, 4, 1) ).
|
2023-05-22 14:37:08 +02:00
|
|
|
|
|
|
|
|
2023-05-22 14:54:45 +02:00
|
|
|
% Setzt das Spielfeld sowie die zugewiesenen einheiten zurück
|
|
|
|
reset_game :-
|
2023-06-05 16:04:22 +02:00
|
|
|
abolish(feld/3),
|
|
|
|
abolish(einheit_active/4),
|
2023-06-23 17:02:49 +02:00
|
|
|
change_player_to(1),
|
2023-06-22 19:13:48 +02:00
|
|
|
abolish(game_window/1),
|
|
|
|
abolish(game_table/1),
|
2023-06-22 22:27:05 +02:00
|
|
|
abolish(game_control/1),
|
2023-06-05 16:04:22 +02:00
|
|
|
abolish(player_tokens/2).
|
2023-05-22 14:54:45 +02:00
|
|
|
|
|
|
|
|
2023-05-22 14:37:08 +02:00
|
|
|
% Initialisiert die Einheiten für die jeweiligen Spieler
|
2023-06-05 16:04:22 +02:00
|
|
|
init_player1(Type1, Type2, Type3) :-
|
2023-05-30 22:53:30 +02:00
|
|
|
% Berechnet die zustehenden Tokens pro Runde für den Spieler
|
2023-06-21 14:31:36 +02:00
|
|
|
einheit(Type1, _, Defense_Points1, _, Cost1, _),
|
|
|
|
einheit(Type2, _, Defense_Points2, _, Cost2, _),
|
|
|
|
einheit(Type3, _, Defense_Points3, _, Cost3, _),
|
2023-06-05 16:04:22 +02:00
|
|
|
|
|
|
|
Player = 1,
|
2023-05-30 22:53:30 +02:00
|
|
|
player_tokens(Tokens),
|
|
|
|
Cost is Tokens - (Cost1 + Cost2 + Cost3),
|
|
|
|
assert( player_tokens(Player, Cost) ),
|
2023-06-12 14:49:23 +02:00
|
|
|
assert( player_tokens_per_turn(Player, Cost) ),
|
2023-05-22 15:56:32 +02:00
|
|
|
|
2023-05-30 22:53:30 +02:00
|
|
|
% Definiert die aktiven einheiten der Spieler
|
|
|
|
% einheit_active(Player, Einheit Type, feldX, feldY)
|
|
|
|
assert( einheit_active(Player,Type1,0,0,Defense_Points1) ),
|
|
|
|
assert( einheit_active(Player,Type2,0,1,Defense_Points2) ),
|
|
|
|
assert( einheit_active(Player,Type3,1,0,Defense_Points3) ).
|
2023-05-22 14:54:45 +02:00
|
|
|
|
2023-06-05 16:04:22 +02:00
|
|
|
init_player2(Type1, Type2, Type3) :-
|
2023-05-22 15:10:00 +02:00
|
|
|
% Berechnet die zustehenden Tokens pro Runde für den Spieler
|
2023-06-21 14:31:36 +02:00
|
|
|
einheit(Type1, _, Defense_Points1, _, Cost1, _),
|
|
|
|
einheit(Type2, _, Defense_Points2, _, Cost2, _),
|
|
|
|
einheit(Type3, _, Defense_Points3, _, Cost3, _),
|
2023-05-30 22:53:30 +02:00
|
|
|
|
2023-06-05 16:04:22 +02:00
|
|
|
Player = 2,
|
2023-05-22 15:10:00 +02:00
|
|
|
player_tokens(Tokens),
|
|
|
|
Cost is Tokens - (Cost1 + Cost2 + Cost3),
|
2023-05-30 18:34:43 +02:00
|
|
|
assert( player_tokens(Player, Cost) ),
|
2023-06-12 14:49:23 +02:00
|
|
|
assert( player_tokens_per_turn(Player, Cost) ),
|
2023-05-30 18:34:43 +02:00
|
|
|
|
|
|
|
% Definiert die aktiven einheiten der Spieler
|
|
|
|
% einheit_active(Player, Einheit Type, feldX, feldY)
|
2023-05-30 22:53:30 +02:00
|
|
|
assert( einheit_active(Player,Type1,4,4,Defense_Points1) ),
|
|
|
|
assert( einheit_active(Player,Type2,4,3,Defense_Points2) ),
|
2023-06-25 10:03:20 +02:00
|
|
|
assert( einheit_active(Player,Type3,3,4,Defense_Points3) ).
|
|
|
|
|
|
|
|
|
|
|
|
% Zur Ausgabe von Infos, falls die Spieler das benötigen
|
|
|
|
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: "),
|
2023-06-25 13:23:03 +02:00
|
|
|
write(Y),
|
2023-06-25 10:03:20 +02:00
|
|
|
write(":"),
|
2023-06-25 13:23:03 +02:00
|
|
|
write(X).
|
2023-06-25 10:03:20 +02:00
|
|
|
|
|
|
|
print_player(Player) :-
|
|
|
|
write("## Player "),
|
|
|
|
write(Player),
|
|
|
|
write(" ##"), nl,
|
|
|
|
forall(einheit_active(Player,Type,X,Y,HP),
|
|
|
|
print_info(Type,X,Y,HP)),
|
|
|
|
|
|
|
|
write("-------"), nl,
|
|
|
|
|
|
|
|
write("Tokens: "),
|
|
|
|
player_tokens(Player,T),
|
|
|
|
write(T).
|
|
|
|
|
|
|
|
print_player1 :-
|
2023-06-25 13:23:03 +02:00
|
|
|
nl,
|
2023-06-25 10:03:20 +02:00
|
|
|
print_player(1).
|
|
|
|
|
|
|
|
print_player2 :-
|
|
|
|
print_player(2).
|
|
|
|
|
|
|
|
% Gibt Infos für den aktuellen Spieler aus
|
|
|
|
info :-
|
|
|
|
current_player(Player),
|
|
|
|
print_player(Player).
|
|
|
|
|
|
|
|
% Gibt Infos für beide Spieler aus
|
|
|
|
info_all :-
|
|
|
|
print_player1,
|
|
|
|
nl, nl, write("=========="), nl, nl,
|
|
|
|
print_player2.
|