File: state.h

package info (click to toggle)
curseofwar 1.1.8-3
  • links: PTS
  • area: main
  • in suites: buster, jessie, jessie-kfreebsd, stretch
  • size: 272 kB
  • sloc: ansic: 2,573; makefile: 47
file content (136 lines) | stat: -rw-r--r-- 3,553 bytes parent folder | download | duplicates (2)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
/******************************************************************************

  Curse of War -- Real Time Strategy Game for Linux.
  Copyright (C) 2013 Alexey Nikolaev.

  This program is free software: you can redistribute it and/or modify
  it under the terms of the GNU General Public License as published by
  the Free Software Foundation, either version 3 of the License, or
  (at your option) any later version.

  This program is distributed in the hope that it will be useful,
  but WITHOUT ANY WARRANTY; without even the implied warranty of
  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
  GNU General Public License for more details.

  You should have received a copy of the GNU General Public License
  along with this program.  If not, see <http://www.gnu.org/licenses/>.
 
******************************************************************************/
#ifndef _STATE_H
#define _STATE_H

#include "common.h"
#include "grid.h"
#include "king.h"

/* 
  faster(s)
    returns a faster speed */
enum config_speed faster(enum config_speed);

/* 
  slower(s)
    returns a slower speed */
enum config_speed slower(enum config_speed);

struct ui {
  struct loc cursor;
  int xskip;
};

/* struct timeline */
struct timeline {
  float data[MAX_PLAYER][MAX_TIMELINE_MARK];  /* stored data */
  unsigned long int time[MAX_TIMELINE_MARK];  /* time when data was recorded */
  int mark; /* the most recently updated time mark.
               It can be used as index in two other fields, i.e.
               0 <= mark < MAX_TIMELINE_MARK */
};


/*
  struct state
    
    Game state

    Members:
      grid in sthe map grid
      flag_grid[] is the array of flag grids (different for each player)
      country[] is the array of countries
      
      king is the array of AI opponents 
      kings_num is the number of AI opponents

      controlled is the player id of the human controlled player

      condiitions is the initial conditions quality (0==random, 1==best, 4==worst)

      inequality (from 0 to 4) is the level of countries' inequality 

      speed and dif are the game speed and the difficulty level
 */
struct state {
  struct grid grid;
  /* struct loc cursor; */
  struct flag_grid fg [MAX_PLAYER];
  struct king king [MAX_PLAYER];
  int kings_num;

  struct timeline timeline;
  int show_timeline;

  struct country country [MAX_PLAYER];

  unsigned long time;

  int map_seed;

  int controlled;

  int conditions;
  int inequality;

  enum config_speed speed;
  enum config_speed prev_speed;
  enum config_dif dif;
};

/*
  state_init(&s, w, h, keep_random, speed, dif)

    initializes state s.

    w and h are the map dimensions
    
    if keep_random == 1, the map is kept random,
    otherwise city and player placement is not arbitrary, 
      but players have their initial locations in the corners of the map.
      function conflict() is used to generate this game mode
 */
void state_init(struct state *s, int w, int h, enum stencil shape,
    unsigned int map_seed, int keep_random, int locations_num, int clients_num,
    int conditions, int inequality, enum config_speed speed, enum config_dif dif,
    int timeline_flag);

/* compute the cursor location, and xskip */
void ui_init(struct state *s, struct ui *ui);

/* 
  kings_move(&s)
    Kings build cities and place flags */

void kings_move(struct state *s);

/*
  simulate(&s)
    Performs one step of the game simulation
 */
void simulate(struct state *s);

/*
  update_timeline(&s)
 */
void update_timeline(struct state *s);

#endif