From 0e7841460148c8007d4dfbbb1c09f472b3ff22e2 Mon Sep 17 00:00:00 2001 From: Yona-TYT Date: Sun, 2 Jun 2024 03:31:55 -0400 Subject: [PATCH] Restructure in convoy analyzer removed --- .../tutorial/class/class_basic_chapter.nut | 44 +++++++++++++++---- .../tutorial/class/class_basic_convoys.nut | 21 ++++++--- .../tutorial/class/class_chapter_07.nut | 2 +- .../scenario/tutorial/scenario.nut | 43 ++++++++++-------- 4 files changed, 75 insertions(+), 35 deletions(-) diff --git a/pak128.prototype/scenario/tutorial/class/class_basic_chapter.nut b/pak128.prototype/scenario/tutorial/class/class_basic_chapter.nut index c5290c2a..8d4b85a2 100644 --- a/pak128.prototype/scenario/tutorial/class/class_basic_chapter.nut +++ b/pak128.prototype/scenario/tutorial/class/class_basic_chapter.nut @@ -229,12 +229,38 @@ class basic_chapter function update_convoy_removed(convoy, pl) { - cov_save[current_cov]=convoy - id_save[current_cov]=convoy.id - if(correct_cov){ - gcov_nr++ - persistent.gcov_nr = gcov_nr + //gui.add_message("update_convoy_removed: "+convoy + " Correct "+correct_cov) + if(cov_save.len() <= current_cov) { + cov_save.push(convoy) + if(correct_cov){ + gcov_nr++ + persistent.gcov_nr = gcov_nr + current_cov = gcov_nr + persistent.current_cov = gcov_nr + } + } + else{ + cov_save[current_cov]=convoy + if(correct_cov){ + gcov_nr++ + persistent.gcov_nr = gcov_nr + current_cov = gcov_nr + persistent.current_cov = gcov_nr + } + } + } + + function is_cov_valid(cnv){ + local result = true + // cnv - convoy_x instance saved somewhat earlier + try { + cnv.get_pos() // will fail if cnv is no longer existent + // do your checks } + catch(ev) { + result = false + } + return result } function cov_pax(c, wt, good){ @@ -943,8 +969,8 @@ class basic_chapter if (cov_dep.x == c_dep.x && cov_dep.y == c_dep.y){ //gui.add_message("("+cov.is_in_depot()+" .. "+cov.id+") .. ??"+id_end+"") if(!cov.is_in_depot()){ - for (local j =id_start ;jgcov_id) gcov_id = id - if (!cov.is_in_depot() && !ignore_save[id]) + if (!cov.is_in_depot() && convoy_ignore(ignore_save, id)) cov_nr++ } return cov_nr } + function convoy_ignore(list, id) + { + for(local j = 0; j "+gcov_nr+":: current covoy-> "+current_cov+":: Correct cov-> "+correct_cov+":: Convoy id-> "+gcov_id+"

" local tx = "" local j=0 - for(j;j id cov save: "+id_save[j]+" :: id conv: "+cov_save[j].id+" ("+cov_save[j].get_pos().tostring()+") "+cov_save[j].get_name()+"
" + tx += "["+j+"] "+cov_save[j].id+"::"+cov_save[j].id+" ("+cov_save[j].get_pos().tostring()+") "+cov_save[j].get_name()+" :: "+cov_save[j].id+"
" } else - tx += "["+j+"] "+id_save[j]+"::"+cov_save[j]+"
" + tx += "["+j+"] "+cov_save[j].id+"::"+cov_save[j]+"
" } - return cov_nr_debug + tx + + return tx */ + //------------------------------------------------------------------------------------------------------------------------------------------------------------------ return chapter.give_title() + chapter.get_rule_text( pl, my_chapter() ) } @@ -486,9 +487,10 @@ function labels_text_debug() function is_scenario_completed(pl) { - //labels_text_debug() + //-------Debug ==================================== //gui.add_message(""+glsw[0]+"") - //gui.add_message("!!!!!"+persistent.step+" ch a "+st_nr[0]+" !!!!! "+persistent.status.step+" -- "+chapter.step+"") + //gui.add_message("!!!!!"+persistent.step+" ch a "+st_nr[0]+" !!!!! "+persistent.status.step+" -- "+chapter.step+"") + //------------------------------------------------------------------------------------------------------------------------------ if (pl != 0) return 0 // other player get only 0% if (currt_pos){ @@ -515,8 +517,9 @@ function is_scenario_completed(pl) gui.open_info_win_at("goal") gui_delay = false } - + //-------Debug ==================================== //gui.add_message(""+current_cov+" "+gall_cov+"") + //------------------------------------------------------------------------------------------------------------------------------ //Para los convoys --------------------- if (gall_cov != current_cov){ basic_convoys().checks_convoy_removed(pl) @@ -529,7 +532,10 @@ function is_scenario_completed(pl) correct_cov = basic_convoys().correct_cov_list() persistent.gall_cov = gall_cov -//gui.add_message("gall_cov-> "+gall_cov+":: gcov_nr-> "+gcov_nr+":: current_cov-> "+current_cov+":: Step-> "+chapter.step+":: PersisStep-> "+persistent.step+":: Status->"+persistent.status.step+"") + //-------Debug ==================================== + //gui.add_message("gall_cov-> "+gall_cov+":: gcov_nr-> "+gcov_nr+":: current_cov-> "+current_cov+":: Step-> "+chapter.step+":: PersisStep-> "+persistent.step+":: Status->"+persistent.status.step+"") + //-------Debug ==================================== + //------------------------------------------------------------------------------------------------------------------------------ if(!correct_cov) { if (!resul_version.pak || !resul_version.st) @@ -574,7 +580,7 @@ function is_scenario_completed(pl) function is_work_allowed_here(pl, tool_id, pos) { local pause = debug.is_paused() - if (pause) return translate("Advance is not allowed with the game paused.") + //if (pause) return translate("Advance is not allowed with the game paused.") //return tile_x(pos.x,pos.y,pos.z).find_object(mo_way).get_dirs() if (pl != 0) return null @@ -616,7 +622,7 @@ function fail_count_message(result, tool_id) function is_schedule_allowed(pl, schedule) { local pause = debug.is_paused() - if (pause) return translate("Advance is not allowed with the game paused.") + //if (pause) return translate("Advance is not allowed with the game paused.") local result = null @@ -633,7 +639,7 @@ function is_schedule_allowed(pl, schedule) function is_convoy_allowed(pl, convoy, depot) { local pause = debug.is_paused() - if (pause) return translate("Advance is not allowed with the game paused.") + //if (pause) return translate("Advance is not allowed with the game paused.") local result = null basic_convoys().checks_convoy_removed(pl) @@ -707,7 +713,6 @@ function resume_game() current_cov = persistent.current_cov gcov_id = persistent.gcov_id sigcoord = persistent.sigcoord - id_save = persistent.id_save ignore_save = persistent.ignore_save pot0=persistent.pot[0]