Skip to content

Commit

Permalink
Agregar la posibilidad de terminar el juego cuando se acaben las fichas
Browse files Browse the repository at this point in the history
  • Loading branch information
cbermudez committed Apr 8, 2020
1 parent 9656ec7 commit 86c7cca
Show file tree
Hide file tree
Showing 2 changed files with 21 additions and 4 deletions.
17 changes: 15 additions & 2 deletions Azul/tiles.pl
Original file line number Diff line number Diff line change
Expand Up @@ -44,13 +44,26 @@
retract(bag(B)),
assert(bag(BR)).

% Build a factory in factory(I, [ F1, F2, F3, F4]).
% Build a factory in factory(I, [ F1, F2, F3, F4]) of with less tiles.
buildFact(_, []) :-
bag([]),
!.
buildFact(FactId, Bag) :-
bag(Bag),
length(Bag, L),
L < 4,
L > 0,
assert(factory(FactId, Bag)),
retract(bag(Bag)),
assert(bag([])),
!.
buildFact(I, [F1, F2, F3, F4]) :-
getTile(F1),
getTile(F2),
getTile(F3),
getTile(F4),
assert(factory(I, [F1, F2, F3, F4])).
assert(factory(I, [F1, F2, F3, F4])),
!.

% Build N factories
buildFacts(0) :- !.
Expand Down
8 changes: 6 additions & 2 deletions game.pl
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@
toBuildFacts(4, 9).

% Start Azul Round with N players
startAzulRound(_) :-
startAzulRound(_) :- % Someone have a row in the wall completed
findall(
PlayerId,
(
Expand All @@ -58,7 +58,11 @@
length(Enders, Len),
Len =\= 0,
Enders=[First|_],
format("El juego termina pues los jugadores ~a han completado una fila~n", [First]),
format("El juego termina pues el jugador ~a ha completado una fila.~n", [First]),
!.
startAzulRound(_) :- % The bag is empty so no more rounds are posible
bag([]),
format("El juego termina pues se han acabado las fichas.~n", _),
!.
startAzulRound(CantPlayers) :-
format("Empezando Nueva Ronda: ~n",_),
Expand Down

0 comments on commit 86c7cca

Please sign in to comment.