OSDN Git Service

日本語版
[nazghul-jp/nazghul-jp.git] / src / factions.h
1 //
2 // nazghul - an old-school RPG engine
3 // Copyright (C) 2002, 2003 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 #ifndef factions_h
24 #define factions_h
25
26 #include "session.h"
27 #include "dtable.h"
28 #include "Being.h"
29
30 #define INVALID_HANDLE      -1
31 #define INVALID_FACTION     -1
32 #define NIL_FACTION          0
33 #define PLAYER_PARTY_FACTION 1
34
35 static inline int are_hostile(Being *a, Being *b)
36 {
37         return dtable_are_hostile(session_dtable(),
38                                   a->getCurrentFaction(),
39                                   b->getCurrentFaction());
40 }
41
42 static inline int are_natively_hostile(Being *a, Being *b)
43 {
44         return dtable_are_hostile(session_dtable(),
45                                   a->getBaseFaction(),
46                                   b->getBaseFaction());
47 }
48
49 static inline int are_allies(Being *a, Being *b)
50 {
51         return dtable_are_allies(session_dtable(),
52                                   a->getCurrentFaction(),
53                                   b->getCurrentFaction());
54 }
55
56 static inline void make_hostile(Being *a, Being *b)
57 {
58         dtable_set(session_dtable(),
59                    a->getCurrentFaction(),
60                    b->getCurrentFaction(),
61                    dtable_hostile(session_dtable()));
62 }
63
64 static inline void make_allies(Being *a, Being *b)
65 {
66         dtable_set(session_dtable(),
67                    a->getCurrentFaction(),
68                    b->getCurrentFaction(),
69                    dtable_allies(session_dtable()));
70 }
71
72 static inline void improve_relations(Being *a, Being *b)
73 {
74         dtable_inc(session_dtable(),
75                    a->getCurrentFaction(),
76                    b->getCurrentFaction());
77 }
78
79 static inline void harm_relations(Being *a, Being *b)
80 {               
81         if (a->getCurrentFaction() != b->getCurrentFaction())
82         {
83         dtable_dec(session_dtable(),
84                    a->getCurrentFaction(),
85                    b->getCurrentFaction());
86         }
87 }
88
89 static inline const char * diplomacy_string(Being *a, Being *b)
90 {
91         return dtable_describe(session_dtable(),
92                                a->getCurrentFaction(),
93                                b->getCurrentFaction());
94 }
95
96 #endif