ref: f5aa8e66aaa6184506d08b27ccd4f2b9b0726f12
dir: /game.c/
#include <u.h>
#include <libc.h>
#include <draw.h>
#include "dat.h"
#include "fns.h"
typedef struct Card Card;
struct Card {
Color col;
int value;
};
State state;
int
c2n(int c, Color col)
{
return c + col*15;
}
State*
getstate()
{
return &state;
}
int
roomaction(int c, int useweapon)
{
int card;
if (!state.running)
return 0;
card = state.room[c];
if (card < 0)
return 0;
// TODO: manage card: fight if enemy, heal if potion, change weapon if weapon card
fprint(2, "card pressed: %d\n", c);
return 1;
}
int
startgame(void)
{
if (state.running)
return 0;
state.running++;
state.canskip = 1;
// TODO: mix cards, update state
// fake display
state.room[0] = c2n(2, Spades);
state.room[1] = c2n(11, Diamonds);
state.room[2] = c2n(14, Clubs);
state.room[3] = c2n(4, Hearts);
state.deckcards = 5;
state.weapon = c2n(6, Diamonds);
state.lastweaponkill = c2n(4, Spades);
return 1;
}
int
nextround(void)
{
if (!state.running)
return 0;
if (!state.canskip)
return 0;
state.canskip = 0;
// TODO: skip round: move cards to end of deck
return 1;
}