scraps

Abandon all hope, ye who enter here.
git clone https://git.neptards.moe/neptards/scraps.git
Log | Files | Refs | Submodules | README | LICENSE

timer.hpp (1446B)


      1 #ifndef GUARD_RETROGRADINGLY_UNSQUARE_LEMON_MERINGUE_PIE_MISCARRIES_2067
      2 #define GUARD_RETROGRADINGLY_UNSQUARE_LEMON_MERINGUE_PIE_MISCARRIES_2067
      3 #pragma once
      4 
      5 #include "scraps/game/action_eval/action_eval_private.hpp"
      6 #include "scraps/game/timer_state.hpp"
      7 
      8 #include <chrono>
      9 #include <cstdint>
     10 #include <exception>
     11 
     12 namespace Scraps::Game { class GameController; }
     13 namespace Scraps::Game::ActionEvalPrivate
     14 {
     15 
     16   struct SingleTimerExec final : EvalItem
     17   {
     18     SingleTimerExec(TimerProxy timer, bool& res) noexcept
     19       : timer{timer}, res{res} {}
     20     ActionResult Call(ActionEvalState& eval, GameController& gc) override;
     21     bool Except(ActionEvalState& eval, GameController& gc,
     22                 const std::exception_ptr& eptr) noexcept override;
     23 
     24     TimerProxy timer;
     25     bool& res;
     26     std::uint8_t state = 0;
     27   };
     28 
     29   struct MultiTimerExec final : EvalItem
     30   {
     31     ActionResult Call(ActionEvalState& eval, GameController& gc) override;
     32 
     33     TimerProxy timer{nullptr};
     34     std::uint32_t i;
     35     bool timer_res;
     36     std::uint8_t state = 0;
     37   };
     38 
     39   struct LiveTimerExec final : EvalItem
     40   {
     41     LiveTimerExec(std::chrono::steady_clock::time_point now = {})
     42       : now{now} {}
     43     ActionResult Call(ActionEvalState& eval, GameController& gc) override;
     44 
     45     std::chrono::steady_clock::time_point now;
     46     TimeDiff diff, min{-1};
     47     TimerProxy timer{nullptr};
     48     std::uint32_t i;
     49     bool timer_res;
     50     std::uint8_t state = 0;
     51   };
     52 }
     53 
     54 #endif