|
From: <lor...@us...> - 2008-11-22 13:47:54
|
Revision: 53
http://deraciel.svn.sourceforge.net/deraciel/?rev=53&view=rev
Author: lordhoto
Date: 2008-11-22 13:47:48 +0000 (Sat, 22 Nov 2008)
Log Message:
-----------
Use char_struct instead of plain stat values to update the stat window.
Modified Paths:
--------------
trunk/char.h
trunk/main.c
trunk/stat.h
trunk/stat_window.c
trunk/stat_window.h
Modified: trunk/char.h
===================================================================
--- trunk/char.h 2008-11-22 13:18:00 UTC (rev 52)
+++ trunk/char.h 2008-11-22 13:47:48 UTC (rev 53)
@@ -6,17 +6,6 @@
#include "inventory.h"
#include "stat.h"
-enum
-{
- STAT_STRENGTH,
- STAT_DEXTERITY,
- STAT_WISDOM,
- STAT_WILLPOWER,
- STAT_CONSTITUTION,
- STAT_CHARISMA,
- STAT_MAX_STATS
-};
-
struct char_struct
{
char name[32];
@@ -26,6 +15,15 @@
uint32_t experience;
uint8_t level;
+ uint32_t turns;
+ uint32_t score;
+
+ int16_t cur_hitpoints;
+ int16_t max_hitpoints;
+
+ int16_t cur_magic;
+ int16_t max_magic;
+
struct invt_struct inventory;
};
Modified: trunk/main.c
===================================================================
--- trunk/main.c 2008-11-22 13:18:00 UTC (rev 52)
+++ trunk/main.c 2008-11-22 13:47:48 UTC (rev 53)
@@ -17,6 +17,21 @@
static void finish(const int);
static void test_keyhandler(const int key);
+static struct char_struct main_char =
+{
+ "Foobar",
+ { 16, 16, 16, 16, 16, 16 },
+ 0,
+ 1,
+ 0,
+ 0,
+ 16,
+ 16,
+ 10,
+ 10,
+ { 0 }
+};
+
int main(int argc, char **argv)
{
signal(SIGINT, finish); /* arrange interrupts to terminate */
@@ -41,6 +56,8 @@
map_window_create();
stat_window_create();
+ invt_init(&main_char.inventory);
+
/* Create keyboard handler */
keyreader_create();
@@ -50,6 +67,8 @@
/* Let thread work */
while(1) { sleep(5); };
+ invt_uninit(&main_char.inventory);
+
finish(0);
return 0;
}
@@ -73,7 +92,6 @@
static int counter = 0;
static chtype map[80*20];
-static stat_t stats[STAT_MAX_STATS] = {0,1,2,3,4,5,6,7,8,9,10,11,12,13,14};
static void test_keyhandler(const int key)
{
@@ -119,7 +137,7 @@
map_window_update(map);
}
- stat_window_update(stats);
+ stat_window_update(&main_char);
doupdate();
}
Modified: trunk/stat.h
===================================================================
--- trunk/stat.h 2008-11-22 13:18:00 UTC (rev 52)
+++ trunk/stat.h 2008-11-22 13:47:48 UTC (rev 53)
@@ -6,21 +6,12 @@
typedef uint32_t stat_t;
enum {
- STAT_CUR_HITPOINTS,
- STAT_MAX_HITPOINTS,
- STAT_CUR_MAGIC,
- STAT_MAX_MAGIC,
STAT_STRENGTH,
STAT_DEXTERITY,
STAT_WISDOM,
STAT_WILLPOWER,
STAT_CONSTITUTION,
STAT_CHARISMA,
- STAT_XP_LEVEL,
- STAT_EXPERIENCE,
- STAT_SCORE,
- STAT_GOLD,
- STAT_TURNS,
STAT_MAX_STATS
};
Modified: trunk/stat_window.c
===================================================================
--- trunk/stat_window.c 2008-11-22 13:18:00 UTC (rev 52)
+++ trunk/stat_window.c 2008-11-22 13:47:48 UTC (rev 53)
@@ -53,7 +53,7 @@
-void stat_window_update(const stat_t *stats)
+void stat_window_update(const struct char_struct *ch)
{
#ifdef STATWINDOW_BORDER
/* Redraw border with new dimensions */
@@ -61,13 +61,13 @@
#endif // !STATWINDOW_BORDER
mvwprintw(border_wnd, 1, 2, "$:%d HP:%d(%d) MP:%d(%d) St:%2d Dx:%2d Co:%2d Wi:%2d Wp:%2d Ch:%2d",
- stats[STAT_GOLD],
- stats[STAT_CUR_HITPOINTS], stats[STAT_MAX_HITPOINTS], stats[STAT_CUR_MAGIC], stats[STAT_MAX_MAGIC],
- stats[STAT_STRENGTH], stats[STAT_DEXTERITY], stats[STAT_CONSTITUTION],
- stats[STAT_WISDOM], stats[STAT_WILLPOWER], stats[STAT_CHARISMA]);
+ *(uint32_t*)(ch->inventory.coins->user_data),
+ ch->cur_hitpoints, ch->max_hitpoints, ch->cur_magic, ch->max_magic,
+ ch->stats[STAT_STRENGTH], ch->stats[STAT_DEXTERITY], ch->stats[STAT_CONSTITUTION],
+ ch->stats[STAT_WISDOM], ch->stats[STAT_WILLPOWER], ch->stats[STAT_CHARISMA]);
- mvwprintw(border_wnd, 2, 2, "Xp:%2d/%d T:%d S:%d",
- stats[STAT_XP_LEVEL], stats[STAT_EXPERIENCE], stats[STAT_SCORE], stats[STAT_TURNS]);
+ mvwprintw(border_wnd, 2, 2, "%s Xp:%2d/%d T:%d S:%d",
+ ch->name, ch->level, ch->experience, ch->score, ch->turns);
wnoutrefresh(border_wnd);
}
Modified: trunk/stat_window.h
===================================================================
--- trunk/stat_window.h 2008-11-22 13:18:00 UTC (rev 52)
+++ trunk/stat_window.h 2008-11-22 13:47:48 UTC (rev 53)
@@ -1,11 +1,11 @@
#ifndef DERACIEL_STAT_WINDOW_H
#define DERACIEL_STAT_WINDOW_H
-#include "stat.h"
+#include "char.h"
void stat_window_create(void);
void stat_window_destroy(void);
-void stat_window_update(const stat_t *stats);
+void stat_window_update(const struct char_struct *ch);
#endif // !DERACIEL_STAT_WINDOW_H
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|