blob: 00b83e25a10adf972f1d9aaa9f9e8a5093d4b320 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
|
#include "m_cockroach.h"
#include "m_common_data.h"
#include "m_house.h"
#include "m_field_info.h"
#include "code_variables.h"
#include "attributes.h"
s32 mCkRh_GokiFamilyCount2Good(s32 count) {
if (count < 0) {
return 0;
}
if (count > mCkRh_MAX_NUM) {
return mCkRh_MAX_NUM;
}
return count;
}
s32 mCkRh_InitGokiSaveData_1Room(s32 player) {
common_data.save.homes[player & 3].goki.num = 0;
common_data.save.homes[player & 3].goki.pad = 0;
common_data.save.homes[player & 3].goki.time.year = common_data.time.rtcTime.year;
common_data.save.homes[player & 3].goki.time.month = common_data.time.rtcTime.month;
common_data.save.homes[player & 3].goki.time.day = common_data.time.rtcTime.day;
}
void mCkRh_InitGokiSaveData_1Room_ByHomeData(mHm_hs_c* home) {
home->goki.num = 0;
home->goki.pad = 0;
home->goki.time.year = common_data.time.rtcTime.year;
home->goki.time.month = common_data.time.rtcTime.month;
home->goki.time.day = common_data.time.rtcTime.day;
}
void mCkRh_InitGokiSaveData_InitNewPlayer() {
s32 i;
for (i = 0; i < PLAYER_NUM; i++) {
mCkRh_InitGokiSaveData_1Room(i);
}
}
void mCkRh_SavePlayTime(s32 player) {
s32 home;
if (player < PLAYER_NUM) {
home = mHS_get_arrange_idx(player) & 3;
common_data.save.homes[home].goki.time.year = common_data.time.rtcTime.year;
common_data.save.homes[home].goki.time.month = common_data.time.rtcTime.month;
common_data.save.homes[home].goki.time.day = common_data.time.rtcTime.day;
}
}
s32 mCkRh_DaysGapCompareWithSaveTime(s32 player) {
s32 home;
s32 pad UNUSED;
if (player < PLAYER_NUM) {
lbRTC_time_c gokiTime;
home = mHS_get_arrange_idx(player) & 3;
gokiTime.year = common_data.save.homes[home].goki.time.year;
gokiTime.month = common_data.save.homes[home].goki.time.month;
gokiTime.day = common_data.save.homes[home].goki.time.day;
gokiTime.weekday = lbRTC_Week(gokiTime.year, gokiTime.month, gokiTime.day);
gokiTime.hour = 1;
gokiTime.min = 1;
gokiTime.sec = 1;
return lbRTC_GetIntervalDays(&gokiTime, &common_data.time.rtcTime);
} else {
return 0;
}
}
void mCkRh_DecideNowGokiFamilyCount(s32 player) {
s32 dayGap;
s32 home;
if (player < PLAYER_NUM) {
dayGap = mCkRh_DaysGapCompareWithSaveTime(player);
home = mHS_get_arrange_idx(player) & 3;
if (dayGap > 6) {
s32 gokiNum;
s32 count;
gokiNum = common_data.save.homes[home].goki.num;
count = gokiNum > 0 ? dayGap : dayGap - 6;
common_data.save.homes[home].goki.num = mCkRh_GokiFamilyCount2Good(count + gokiNum);
}
}
}
s32 mCkRh_PlussGokiN_NowRoom(s32 count) {
u16 fieldId = mFI_GetFieldId();
s32 player;
s32 housefieldId;
s32 homeId;
s32 num;
s32 pad[1] UNUSED;
if (FI_IS_PLAYER_ROOM(fieldId)) {
player = common_data.playerNumber;
housefieldId = FI_GET_PLAYER_ROOM_NO(fieldId);
homeId = mHS_get_arrange_idx(player) & 3;
if ((player < PLAYER_NUM) && (housefieldId == homeId)) {
num = common_data.save.homes[homeId].goki.num;
common_data.save.homes[homeId].goki.num = mCkRh_GokiFamilyCount2Good(count + num);
return TRUE;
}
}
return FALSE;
}
s32 mCkRh_MinusGokiN_NowRoom(s32 count) {
u16 fieldId = mFI_GetFieldId();
s32 player;
s32 housefieldId;
s32 homeId;
s32 num;
s32 pad[1] UNUSED;
if (FI_IS_PLAYER_ROOM(fieldId)) {
player = common_data.playerNumber;
housefieldId = FI_GET_PLAYER_ROOM_NO(fieldId);
homeId = mHS_get_arrange_idx(player) & 3;
if ((player < PLAYER_NUM) && (housefieldId == homeId)) {
num = common_data.save.homes[homeId].goki.num;
common_data.save.homes[homeId].goki.num = mCkRh_GokiFamilyCount2Good(num - count);
return TRUE;
}
}
return FALSE;
}
s32 mCkRh_NowSceneGokiFamilyCount() {
u16 fieldid = mFI_GetFieldId();
if (FI_IS_PLAYER_ROOM(fieldid)) {
return common_data.save.homes[FI_GET_PLAYER_ROOM_NO(fieldid)].goki.num;
} else {
return 0;
}
}
void mCkRh_InitCanLookGokiCount() {
CanLookGokiCount = 0;
}
s32 mCkRh_CalcCanLookGokiCount(s32 count) {
s32 calc = count + CanLookGokiCount;
if (calc < 0) {
CanLookGokiCount = 0;
return FALSE;
}
if (calc > mCkRh_MAX_LOOK_NUM) {
CanLookGokiCount = mCkRh_MAX_LOOK_NUM;
return FALSE;
}
CanLookGokiCount = calc;
return TRUE;
}
s32 mCkRh_GetCanLookGokiCount() {
return CanLookGokiCount;
}
|