Mercurial > molko
comparison libmlk-rpg/rpg/battle.c @ 289:63d9fb56c609
rpg: rework selection
author | David Demelier <markand@malikania.fr> |
---|---|
date | Thu, 07 Jan 2021 15:52:56 +0100 |
parents | 3991779aaba9 |
children | 9948e288925b |
comparison
equal
deleted
inserted
replaced
288:cc0f02ae9005 | 289:63d9fb56c609 |
---|---|
288 | 288 |
289 void | 289 void |
290 battle_cast(struct battle *bt, | 290 battle_cast(struct battle *bt, |
291 struct character *source, | 291 struct character *source, |
292 const struct spell *spell, | 292 const struct spell *spell, |
293 unsigned int selection) | 293 const struct selection *selection) |
294 { | 294 { |
295 assert(bt); | 295 assert(bt); |
296 assert(source); | 296 assert(source); |
297 assert(spell); | 297 assert(spell); |
298 assert((unsigned int)source->mp >= spell->mp); | 298 assert((unsigned int)source->mp >= spell->mp); |
312 | 312 |
313 if (!bt->order_cur) { | 313 if (!bt->order_cur) { |
314 battle_order(bt); | 314 battle_order(bt); |
315 bt->order_cur = bt->order[bt->order_curindex = 0]; | 315 bt->order_cur = bt->order[bt->order_curindex = 0]; |
316 } else { | 316 } else { |
317 /* End of turn. */ | 317 for (++bt->order_curindex; bt->order_curindex < BATTLE_ENTITY_MAX; ++bt->order_curindex) { |
318 if (++bt->order_curindex >= BATTLE_ENTITY_MAX || !bt->order[bt->order_curindex]) { | 318 if (battle_entity_ok(bt->order[bt->order_curindex])) { |
319 bt->order_cur = bt->order[bt->order_curindex]; | |
320 break; | |
321 } | |
322 } | |
323 | |
324 /* End of "turn". */ | |
325 if (bt->order_curindex >= BATTLE_ENTITY_MAX) { | |
319 battle_order(bt); | 326 battle_order(bt); |
320 bt->order_cur = bt->order[bt->order_curindex = 0]; | 327 bt->order_cur = bt->order[bt->order_curindex = 0]; |
321 } else | 328 } |
322 bt->order_cur = bt->order[bt->order_curindex]; | |
323 } | 329 } |
324 | 330 |
325 /* Change state depending on the kind of entity. */ | 331 /* Change state depending on the kind of entity. */ |
326 if (is_team(bt, bt->order_cur->ch)) { | 332 if (is_team(bt, bt->order_cur->ch)) { |
327 battle_bar_open_menu(&bt->bar); | 333 battle_bar_open_menu(&bt->bar); |