#CLASS {missiontimers} {kill};
#CLASS {missiontimers} {open};

#NOP ==[ Load Individual Mission stuff ]==
#READ {src/missions/sausages.tin};
#READ {src/missions/letters.tin};
#READ {src/missions/sailing.tin};


#ALIAS {missions} {
    #if {&missions == 0} { 
        #return;
    };

    #format {current_time} {%T};
    #var {mission_display_list} {};

    #nop ==============================;
    #nop =====  Sailing Missions  =====;
    #nop ==============================;
    #if {&missions[sailing]} {
        #foreach {$missions[sailing][active_list][]} {player} {
            #math {mins} {$current_time - $missions[sailing][active_list][$player]};
            #math {mins} {($mins - (60 - 1)) / 60};

            #math {mins} {120 - $mins};

            #math {hours} {$mins / 60};
            #math {mins} {$mins % 60};

            #if {$mins < 0} {
                #unvar {missions[sailing][active_list][$player]};
            }  {
                #format {mt_display} {\t<129>%s<099> can do another sailing mission in <139>%d<099> hour and <139>%d<099> minutes.<099>} {$player}{$hours}{$mins};
                #list {mission_display_list[$player]} {add} {$mt_display};
            };
        };
    };


    #nop ==============================;
    #nop =====  Sausage Missions  =====;
    #nop ==============================;
    #if {&missions[sausage]} {
        #foreach {$missions[sausage][active_list][]} {player} {
            #if {&missions[sausage][active_list][$player][easy]} {
                #math {mins} {$current_time - $missions[sausage][active_list][$player][easy]};
                #math {mins} {($mins - (60 - 1)) / 60};

                #math {mins} {60 - $mins};

                #format {mt_display} {\t<129>%s<099> can do another unspiced sausage mission in <139>%d<099> minutes.<099>} {$player}{$mins};
                #list {mission_display_list[$player]} {add} {$mt_display};
            };

            #if {&missions[sausage][active_list][$player][hard]} {
                #math {mins} {$current_time - $missions[sausage][active_list][$player][hard]};
                #math {mins} {($mins - (60 - 1)) / 60};

                #math {mins} {60 - $mins};

                #format {mt_display} {\t<129>%s<099> can do another spiced sausage mission in <139>%d<099> minutes.<099>} {$player}{$mins};
                #list {mission_display_list[$player]} {add} {$mt_display};
            };
        };

        #foreach {$missions[sausage][retry_list][]} {player} {
            #math {mins} {$current_time - $missions[sausage][retry_list][$player]};
            #math {mins} {($mins - (60 - 1)) / 60};

            #math {mins} {10 - $mins};

            #format {mt_display} {\t<129>%s<099> can request a new sausage mission in <139>%d<099> minutes.<099>} {$player}{$mins};
            #list {mission_display_list[$player]} {add} {$mt_display};
        };
    };

    #nop ==============================;
    #nop =====    Dead Letters    =====;
    #nop ==============================;
    #if {&missions[letter]} {
        #foreach {$missions[letter][active_list][]} {player} {
            #if {&missions[letter][active_list][$player][difficult]} {
                #math {mins} {$current_time - $missions[letter][active_list][$player][difficult]};
                #math {mins} {($mins - (60 - 1)) / 60};

                #math {mins} {60 - $mins};

                #if {$mins < 0} {
                    #unvar {missions[letter][active_list][$player][difficult]};
                } {
                    #format {mt_display} {\t<129>%s<099> can do another difficult customer letter in <139>%d<099> minutes.<099>} {$player}{$mins};
                    #list {mission_display_list[$player]} {add} {$mt_display};
                };
            };
            #if {&missions[letter][active_list][$player][distant]} {
                #math {mins} {$current_time - $missions[letter][active_list][$player][distant]};
                #math {mins} {($mins - (60 - 1)) / 60};

                #math {mins} {60 - $mins};

                #if {$mins < 0} {
                    #unvar {missions[letter][active_list][$player][distant]};
                } {
                    #format {mt_display} {\t<129>%s<099> can do another distant lands letter in <139>%d<099> minutes.<099>} {$player}{$mins};
                    #list {mission_display_list[$player]} {add} {$mt_display};
                };
            };
            #if {&missions[letter][active_list][$player][far]} {
                #math {mins} {$current_time - $missions[letter][active_list][$player][far]};
                #math {mins} {($mins - (60 - 1)) / 60};

                #math {mins} {60 - $mins};

                #if {$mins < 0} {
                    #unvar {missions[letter][active_list][$player][far]};
                } {
                    #format {mt_display} {\t<129>%s<099> can do another far away letter in <139>%d<099> minutes.<099>} {$player}{$mins};
                    #list {mission_display_list[$player]} {add} {$mt_display};
                };
            };
            #if {&missions[letter][active_list][$player][close]} {
                #math {mins} {$current_time - $missions[letter][active_list][$player][close]};
                #math {mins} {($mins - (60 - 1)) / 60};

                #math {mins} {60 - $mins};

                #if {$mins < 0} {
                    #unvar {missions[letter][active_list][$player][close]};
                } {
                    #format {mt_display} {\t<129>%s<099> can do another close-by letter in <139>%d<099> minutes.<099>} {$player}{$mins};
                    #list {mission_display_list[$player]} {add} {$mt_display};
                };
            };
            #if {&missions[letter][active_list][$player][local]} {
                #math {mins} {$current_time - $missions[letter][active_list][$player][local]};
                #math {mins} {($mins - (60 - 1)) / 60};

                #math {mins} {60 - $mins};

                #if {$mins < 0} {
                    #unvar {missions[letter][active_list][$player][local]};
                } {
                    #format {mt_display} {\t<129>%s<099> can do another local letter in <139>%d<099> minutes.<099>} {$player}{$mins};
                    #list {mission_display_list[$player]} {add} {$mt_display};
                };
            };
        };

        #foreach {$missions[letter][retry_list][]} {player} {
            #math {mins} {$current_time - $missions[letter][retry_list][$player]};
            #math {mins} {($mins - (60 - 1)) / 60};

            #math {mins} {10 - $mins};

            #if {$mins < 0} {
                #unvar {missions[letter][retry_list][player]};
            } {
                #format {mt_display} {\t<129>%s<099> can request another letter in <139>%d<099> minutes.<099>} {$player}{$mins};
                #list {mission_display_list[$player]} {add} {$mt_display};
            };
        };

    };


    #nop ==============================;
    #nop =====   Print Missions   =====;
    #nop ==============================;
    #list {mission_display_list} {size} {mdl_count};
    #if {$mdl_count > 0} {
        #echo {<149>[MT] Active Mission Timers:<099>}; 
        #foreach {$mission_display_list[]} {player} {
            #foreach {$mission_display_list[$player][%*]} {mt_display} {
                #showme {$mt_display};
            };
        };
    } {
        #echo {<149>[MT] No current mission timers.<099>};
    };

};

#CLASS {missiontimers} {close};
