record and replay spellcasting

This commit is contained in:
2024-08-26 20:36:48 -05:00
committed by Celtic Minstrel
parent b5fa2db5fd
commit 532a1e3236
3 changed files with 33 additions and 3 deletions

View File

@@ -249,7 +249,12 @@ bool prime_time() {
return overall_mode == MODE_OUTDOORS || overall_mode == MODE_TOWN || overall_mode == MODE_COMBAT;
}
static void handle_spellcast(eSkill which_type, bool& did_something, bool& need_redraw, bool& need_reprint) {
void handle_spellcast(eSkill which_type, bool& did_something, bool& need_redraw, bool& need_reprint, bool record) {
if(record && recording){
std::ostringstream sstr;
sstr << which_type;
record_action("handle_spellcast", sstr.str());
}
short store_sp[6];
extern short spec_target_fail;
extern eSpecCtxType spec_target_type;
@@ -673,7 +678,12 @@ static void handle_talk(location destination, bool& did_something, bool& need_re
}
}
static void handle_target_space(location destination, bool& did_something, bool& need_redraw, bool& need_reprint) {
void handle_target_space(location destination, bool& did_something, bool& need_redraw, bool& need_reprint) {
if(recording){
std::ostringstream sstr;
sstr << destination;
record_action("handle_target_space", sstr.str());
}
if(overall_mode == MODE_SPELL_TARGET)
do_combat_cast(destination);
else if(overall_mode == MODE_THROWING || overall_mode == MODE_FIRING)
@@ -1615,6 +1625,12 @@ bool someone_awake() {
void handle_menu_spell(eSpell spell_picked) {
if(recording){
std::ostringstream sstr;
sstr << (int)spell_picked;
record_action("handle_menu_spell", sstr.str());
}
eSkill spell_type = (*spell_picked).type;
if(!prime_time()) {
ASB("Finish what you're doing first.");
@@ -1639,7 +1655,7 @@ void handle_menu_spell(eSpell spell_picked) {
}
bool did_something = false, need_redraw = false, need_reprint = false;
handle_spellcast(spell_type, did_something, need_redraw, need_reprint);
handle_spellcast(spell_type, did_something, need_redraw, need_reprint, false);
advance_time(did_something, need_redraw, need_reprint);
}

View File

@@ -62,5 +62,7 @@ void handle_begin_look(bool right_button, bool& need_redraw);
void handle_look(location destination, bool right_button, eKeyMod mods, bool& need_redraw, bool& need_reprint);
void screen_shift(int dx, int dy, bool& need_redraw);
void handle_rest(bool& need_redraw, bool& need_reprint);
void handle_spellcast(eSkill which_type, bool& did_something, bool& need_redraw, bool& need_reprint, bool record = true);
void handle_target_space(location destination, bool& did_something, bool& need_redraw, bool& need_reprint);
#endif

View File

@@ -425,6 +425,18 @@ static void replay_next_action() {
screen_shift(dx, dy, need_redraw);
}else if(t == "handle_rest"){
handle_rest(need_redraw, need_reprint);
}else if(t == "handle_menu_spell"){
eSpell spell_picked = static_cast<eSpell>(std::stoi(next_action.GetText()));
handle_menu_spell(spell_picked);
}else if(t == "handle_spellcast"){
std::istringstream sstr(next_action.GetText());
eSkill which_type;
sstr >> which_type;
handle_spellcast(which_type, did_something, need_redraw, need_reprint);
}else if(t == "handle_target_space"){
location destination = location_from_action(next_action);
handle_target_space(destination, did_something, need_redraw, need_reprint);
}
// TODO some of these actions shouldn't call advance_time(). They should return