Revert revision [536] to avoid making further changes on an unstable
[neverball] / ball / level.h
1 #ifndef LEVEL_H
2 #define LEVEL_H
3
4 #include "base_config.h"
5 #define NSCORE  3
6
7 /*---------------------------------------------------------------------------*/
8
9 struct score
10 {
11     char player[NSCORE + 1][MAXNAM];
12
13     int  timer [NSCORE + 1]; /* Time elapsed    */
14     int  coins [NSCORE + 1]; /* Coins collected */
15 };
16
17 void score_init_hs(struct score *, int, int);
18
19 /*---------------------------------------------------------------------------*/
20
21 struct level
22 {
23     char file[PATHMAX];
24     char back[PATHMAX];
25     char grad[PATHMAX];
26     char shot[PATHMAX];
27     char song[PATHMAX];
28
29     char message[MAXSTR];
30
31     char version[MAXSTR];
32     char author[MAXSTR];
33
34     int time; /* Time limit   */
35     int goal; /* Coins needed */
36
37     struct
38     {
39         struct score best_times;
40         struct score unlock_goal;
41         struct score most_coins;
42     }
43     score;
44
45     /* Set information. */
46
47     struct set *set;
48
49     int  number;
50     char repr[3]; /* String representation of the number (eg. "B1") */
51
52     int is_locked;
53     int is_bonus;
54     int is_completed;
55 };
56
57 int level_load(const char *, struct level *);
58
59 void level_dump_info(const struct level *);
60
61 /*---------------------------------------------------------------------------*/
62
63 /* A level for the playing */
64
65 struct level_game
66 {
67     int mode;          /* game mode */
68     const struct level *level; /* the level played */
69
70     int goal;          /* coins needed */
71     int time;          /* time limit */
72
73     /* MODE_CHALLENGE only */
74     int score;         /* coin total */
75     int balls;         /* live count */
76     int times;         /* time total */
77
78     /* Once a level is finished */
79     int state;         /* state ending */
80     int coins;         /* coins collected */
81     int timer;         /* time elapsed */
82     int state_value;   /* more precision about the state: skip for goal */
83
84     /* rank = 3  => unclassed */
85     int coin_rank;     /* rank in the level high-scores */
86     int goal_rank;     /* rank in the level high-scores */
87     int time_rank;     /* rank in the level high-scores */
88     int score_rank;    /* rank in the set high-scores */
89     int times_rank;    /* rank in the set high-scores */
90
91     /* What about the game and the set? */
92     int dead;          /* Is the game over and lost? */
93     int win;           /* Is the game over and win? */
94     int unlock;        /* Is the next level newly unlocked */
95     const struct level *next_level; /* next level (NULL no next level) */
96 };
97
98 /*---------------------------------------------------------------------------*/
99
100 #define MODE_CHALLENGE  1
101 #define MODE_NORMAL     2
102 #define MODE_PRACTICE   3
103 #define MODE_SINGLE     4
104
105 const char *mode_to_str(int);
106
107 /*---------------------------------------------------------------------------*/
108
109 #define GAME_NONE 0     /* No event (or aborted) */
110 #define GAME_TIME 1     /* Time's up */
111 #define GAME_GOAL 2     /* Goal reached */
112 #define GAME_FALL 3     /* Fall out */
113 #define GAME_SPEC 4     /* Special goal reached */
114
115 const char *state_to_str(int);
116
117 #endif