TheChess

model/GameParameters.hpp

00001 /*
00002  * thechess, chess game web application written in C++ and based on Wt
00003  * Copyright (C) 2010 Boris Nagaev
00004  *
00005  * thechess is licensed under the GNU GPL Version 2.
00006  * Other versions of the GPL do not apply.
00007  * See the LICENSE file for terms of use.
00008  */
00009 
00010 #ifndef THECHESS_MODEL_GAMAPARAMATERS_HPP_
00011 #define THECHESS_MODEL_GAMAPARAMATERS_HPP_
00012 
00013 #include <Wt/Dbo/Dbo>
00014 #include <Wt/Dbo/ptr>
00015 namespace dbo = Wt::Dbo;
00016 
00017 namespace thechess {
00018 namespace model {
00019 class GameParameters;
00020 }
00021 }
00022 
00023 #include "chess/moves.hpp"
00024 #include "chess/field.hpp"
00025 #include "time_intervals.hpp"
00026 
00027 namespace thechess {
00028 namespace model {
00029 
00030 class GameParameters {
00031 public:
00032     GameParameters();
00033     GameParameters(bool);
00034 
00035     template<class Action>
00036     void persist(Action& a) {
00037         dbo::field(a, moves_.as_svuc(), "moves");
00038         dbo::field(a, moves_init_, "moves_init");
00039         dbo::field(a, limit_std_, "limit_std");
00040         dbo::field(a, limit_private_init_, "limit_private_init_");
00041         dbo::field(a, norating_, "norating");
00042         dbo::field(a, pause_limit_init_, "pause_limit_init");
00043         dbo::field(a, first_draw_, "first_draw");
00044     }
00045 
00046     const chess::Moves& moves() const {
00047         return moves_;
00048     }
00049 
00050     void set_init_moves(const chess::Moves& moves) {
00051         moves_ = moves;
00052         moves_init_ = moves_.size();
00053     }
00054 
00055     int moves_init() const {
00056         return moves_init_;
00057     }
00058 
00059     const Td& limit_std() const {
00060         return limit_std_;
00061     }
00062     void set_limit_std(const Td& limit_std) {
00063         limit_std_ = limit_std;
00064     }
00065 
00066     const Td& limit_private_init() const {
00067         return limit_private_init_;
00068     }
00069     void set_limit_private_init(const Td& limit_private_init) {
00070         limit_private_init_ = limit_private_init;
00071     }
00072 
00073     bool norating() const {
00074         return norating_;
00075     }
00076     void set_norating(bool norating) {
00077         norating_ = norating;
00078     }
00079 
00080     const Td& pause_limit_init() const {
00081         return pause_limit_init_;
00082     }
00083     void set_pause_limit_init(const Td& pause_limit_init) {
00084         pause_limit_init_ = pause_limit_init;
00085     }
00086 
00087     int first_draw() const {
00088         return first_draw_;
00089     }
00090     void set_first_draw(int first_draw) {
00091         first_draw_ = first_draw;
00092     }
00093 
00094     void set_game_parameters(const GameParameters* other);
00095     void set_no_draw();
00096 
00097 protected:
00098     chess::Moves moves_;
00099 
00100 private:
00101     int moves_init_;
00102 
00103     Td limit_std_;
00104     Td limit_private_init_;
00105     Td pause_limit_init_;
00106 
00107     bool norating_;
00108 
00109     int first_draw_;
00110 };
00111 
00112 const int NO_DRAW = -1;
00113 
00114 }
00115 }
00116 
00117 #endif
 All Classes Functions Enumerations Enumerator