OSDN Git Service

日本語版
[nazghul-jp/nazghul-jp.git] / src / ztats_spells.c
1 /*
2  * nazghul - an old-school RPG engine
3  * Copyright (C) 2008 Gordon McNutt
4  *
5  * This program is free software; you can redistribute it and/or modify it
6  * under the terms of the GNU General Public License as published by the Free
7  * Software Foundation; either version 2 of the License, or (at your option)
8  * any later version.
9  *
10  * This program is distributed in the hope that it will be useful, but WITHOUT
11  * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
12  * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License for
13  * more details.
14  *
15  * You should have received a copy of the GNU General Public License along with
16  * this program; if not, write to the Free Foundation, Inc., 59 Temple Place,
17  * Suite 330, Boston, MA 02111-1307 USA
18  *
19  * Gordon McNutt
20  * gmcnutt@users.sourceforge.net
21  */
22
23 #include "ztats_spells.h"
24
25 #include "magic.h"
26 #include "screen.h"
27 #include "session.h"
28 #include "sprite.h"
29 #include "ztats.h"
30 #include "ztats_container_pane.h"
31
32 static void ztats_spells_paint_item(struct inv_entry *ie, SDL_Rect *rect)
33 {
34         char code[MAX_SYLLABLES_PER_SPELL+1] = { 0 };
35         struct spell *spell = 0;
36
37         /* This assumes the type name matches the spelled-out code name, and
38          * doesn't include extra stuff like " spell" at the end. Eg, "Vas Flam"
39          * is great but "Vas Flam spell" will come back as "Vas Flam Sanct" or
40          * possibly an error. */
41         if (! magic_spell_name_to_code(&Session->magic, code, sizeof(code), ie->type->getName())) {
42                 spell = magic_lookup_spell(&Session->magic, code);
43         }
44
45         /* Blit the sprite on the left */
46         if (spell && spell->sprite) {
47                 sprite_paint(spell->sprite, 0, rect->x, rect->y);
48         }
49         rect->x += TILE_W;
50
51         /* Print basic info available in the type. */
52         screenPrint(rect, 0, "%2d %s", ie->count, ie->type->getName());
53         rect->y += ASCII_H;
54
55         /* Print info only available in the spell struct. */
56         if (spell) {
57                 screenPrint(rect, 0, 
58                         "^c+G¥ì¥Ù¥ë:^c+y%d^c- ËâÎÏ:^c+b%d^c- ¹ÔÆ°:^c+r%d^c-^c-",
59                         spell->level, 
60                         spell->cost, spell->action_points);
61         }
62
63         /* Carriage-return line-feed */
64         rect->y += ASCII_H;
65         rect->x -= TILE_W;
66 }
67
68 static bool ztats_spells_filter_cb(struct inv_entry *ie, void *fdata)
69 {
70         return (ie->type->isCastable());
71 }
72
73
74 void ztats_spells_init(void)
75 {
76         static struct ztats_container_pane pane;
77         static struct ztats_container_pane_ops ops = {
78                 ztats_spells_paint_item
79         };
80         static struct filter filter = {
81                 ztats_spells_filter_cb,
82                 NULL
83         };
84
85         ztats_container_pane_init(&pane, "¼öʸ", &filter, &ops);
86         ztats_add_pane(&pane.base);
87 }