Post by Perun on Dec 29, 2003 11:05:57 GMT
Jean-Yves,
I don't know how you implemented (or did you) flagging for finished games, but here's a thought:
Regicide
After each turn, check is made against status of all kings. If only one is alive, game is flagged finished in the database and doesn't display anymore in active games list on the main list, as well as in individual player lists.
example:
select id from kings where alive=true
or
select count(id) from kings where alive=true
if recordcount>1 then there is more than 1 king alive, or if count>1 then the same
Military conquest
Same as above, but another check is made to see if there's more than one owner of the lords. If not, game is over.
example: if you use method 1 in Regicide check, and save the result then you can use
select count(id) from lords where owner !=result
if count>0 then game is not over yet
World domination
Same as militray conquest, yet another check is made to see if all citadels have more than one owner. If so, game obviously isn't over yet.
example: again, if you use method 1 in Regicide check, and save the result then you can use
select count(id) from strongholds where type=citadel and owner !=result
if count>0 then game isn't over yet
In the end, if checking returns true, then one simple final
update games set finished=true where id=current_game_id
should close the game.
I think that these few checks wouldn't slow down game significantly, since they would be performed only on "End turn" click. And there shouldn't be much database use, since these checks are all simple COUNT selects. And since we almost always choose Regicide, only one simple select is used in most cases.
I don't try to be smart, just making a suggestion. ;D Hope you don't mind.
I don't know how you implemented (or did you) flagging for finished games, but here's a thought:
Regicide
After each turn, check is made against status of all kings. If only one is alive, game is flagged finished in the database and doesn't display anymore in active games list on the main list, as well as in individual player lists.
example:
select id from kings where alive=true
or
select count(id) from kings where alive=true
if recordcount>1 then there is more than 1 king alive, or if count>1 then the same
Military conquest
Same as above, but another check is made to see if there's more than one owner of the lords. If not, game is over.
example: if you use method 1 in Regicide check, and save the result then you can use
select count(id) from lords where owner !=result
if count>0 then game is not over yet
World domination
Same as militray conquest, yet another check is made to see if all citadels have more than one owner. If so, game obviously isn't over yet.
example: again, if you use method 1 in Regicide check, and save the result then you can use
select count(id) from strongholds where type=citadel and owner !=result
if count>0 then game isn't over yet
In the end, if checking returns true, then one simple final
update games set finished=true where id=current_game_id
should close the game.
I think that these few checks wouldn't slow down game significantly, since they would be performed only on "End turn" click. And there shouldn't be much database use, since these checks are all simple COUNT selects. And since we almost always choose Regicide, only one simple select is used in most cases.
I don't try to be smart, just making a suggestion. ;D Hope you don't mind.