Replace strong level path from replay with a couple (name/version) of the level.
[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 levelname[MAXSTR];
32     char version[MAXSTR];
33     char author[MAXSTR];
34
35     int time; /* Time limit   */
36     int goal; /* Coins needed */
37
38     struct
39     {
40         struct score best_times;
41         struct score unlock_goal;
42         struct score most_coins;
43     }
44     score;
45
46     /* Set information. */
47
48     struct set *set;
49
50     int  number;
51     char repr[3]; /* String representation of the number (eg. "B1") */
52
53     int is_locked;
54     int is_bonus;
55     int is_completed;
56 };
57
58 int level_load(const char *, struct level *);
59
60 void level_dump_info(const struct level *);
61
62 /*---------------------------------------------------------------------------*/
63
64 /* A level for the playing */
65
66 struct level_game
67 {
68     int mode;          /* game mode */
69     const struct level *level; /* the level played */
70
71     int goal;          /* coins needed */
72     int time;          /* time limit */
73
74     /* MODE_CHALLENGE only */
75     int score;         /* coin total */
76     int balls;         /* live count */
77     int times;         /* time total */
78
79     /* Once a level is finished */
80     int state;         /* state ending */
81     int coins;         /* coins collected */
82     int timer;         /* time elapsed */
83     int state_value;   /* more precision about the state: skip for goal */
84
85     /* rank = 3  => unclassed */
86     int coin_rank;     /* rank in the level high-scores */
87     int goal_rank;     /* rank in the level high-scores */
88     int time_rank;     /* rank in the level high-scores */
89     int score_rank;    /* rank in the set high-scores */
90     int times_rank;    /* rank in the set high-scores */
91
92     /* What about the game and the set? */
93     int dead;          /* Is the game over and lost? */
94     int win;           /* Is the game over and win? */
95     int unlock;        /* Is the next level newly unlocked */
96     const struct level *next_level; /* next level (NULL no next level) */
97 };
98
99 /*---------------------------------------------------------------------------*/
100
101 #define MODE_CHALLENGE  1
102 #define MODE_NORMAL     2
103 #define MODE_PRACTICE   3
104 #define MODE_SINGLE     4
105
106 const char *mode_to_str(int);
107
108 /*---------------------------------------------------------------------------*/
109
110 #define GAME_NONE 0     /* No event (or aborted) */
111 #define GAME_TIME 1     /* Time's up */
112 #define GAME_GOAL 2     /* Goal reached */
113 #define GAME_FALL 3     /* Fall out */
114 #define GAME_SPEC 4     /* Special goal reached */
115
116 const char *state_to_str(int);
117
118 #endif