diff options
author | Nathan Vance <nathav63@gmail.com> | 2015-03-30 15:35:36 -0400 |
---|---|---|
committer | Nathan Vance <nathav63@gmail.com> | 2015-03-30 15:35:36 -0400 |
commit | ac78ebaf7f7e9d96cb022ad8a14fc013a58ba262 (patch) | |
tree | fe3042b52fc061c88a9b9dc0b51883f7fa0781cb /special_actions.c | |
parent | Discards are now tracked (diff) | |
download | 7w-ac78ebaf7f7e9d96cb022ad8a14fc013a58ba262.tar.gz 7w-ac78ebaf7f7e9d96cb022ad8a14fc013a58ba262.tar.bz2 7w-ac78ebaf7f7e9d96cb022ad8a14fc013a58ba262.zip |
Started work on special wonder actions
Diffstat (limited to 'special_actions.c')
-rw-r--r-- | special_actions.c | 88 |
1 files changed, 88 insertions, 0 deletions
diff --git a/special_actions.c b/special_actions.c new file mode 100644 index 0000000..5b6e0ed --- /dev/null +++ b/special_actions.c @@ -0,0 +1,88 @@ +#include "7w.h" + +int* data_getdiscards(); +void data_deletediscard(int era, int card); +void data_build(int p, int card); +void data_setspecialflag(int p); +int data_numplayers(); +int data_turnnum(); +int print_cards(int x, int y, int *cards, int cursor); +int io_printtext(int xorigin, int y, int width, char* text); +void io_printborder(int x, int y, int width); +int io_getkey(); +void posthelp(); +int data_isai(int p); + +void Halicarnassus(int player) +{ + int x = 61; + int y = 0; + int focus = data_numplayers(); + int i; + int cursor = 0; + int *discards = data_getdiscards(); + int numcards = 0; + int bottom = 0; + while(discards[numcards++] != -1 && numcards < 50); + numcards /= 2; + io_printborder(x, y++, 28); + y = io_printtext(x, y, 28, " Discards"); + while(1) { + bottom = print_cards(x, y, discards, cursor); + switch(io_getkey()) { + case UP: cursor--; + break; + case DOWN: cursor++; + break; + case RIGHT: focus++; + cursor = 0; + break; + case LEFT: focus--; + cursor = 0; + break; + case '\t': focus = (focus+1)%(data_numplayers()+1); + cursor = 0; + break; + case 'h': posthelp(); + break; + case ENTER: + if(data_hasbuiltname(player, discards[cursor*2], discards[cursor*2+1])) { + postmessage("Cannot have two of the same card!"); + } + else { + data_freebuild(player, discards[cursor*2], discards[cursor*2+1]); + data_deletediscard(discards[cursor*2], discards[cursor*2+1]); + return; + } + default: break; + } + if(focus < 0) focus = data_numplayers(); + focus = focus%(data_numplayers()+1); + if(focus == data_numplayers()) { + if(cursor < 0) cursor = numcards-1; + if(cursor >= numcards) cursor = 0; + } + else { + if(cursor < 0) cursor = wonder_numstages((player+focus)%data_numplayers())+data_numbuilt(player+focus%data_numplayers())-1; + cursor = cursor % (wonder_numstages((player+focus)%data_numplayers())+data_numbuilt(player+focus%data_numplayers())); + } + } +} + +void special_action(int player, int wonder, int stage) +{ + if(wonder == 8) { //Halicarnassus + if(stage == 2 || stage == 4 || stage == 5 || stage == 6) + if(data_isai(player)); + else Halicarnassus(player); + } + if(wonder == 6) { //Babylon + if(stage >= 5) { + if(data_turnnum() < 6) data_setspecialflag(player); + else { + if(data_isai(player)); + else; + } + } + } +} |