Tagua now compiles with QT_NO_KEYWORDS. Boost 1.34 is required.
[tagua/yd.git] / src / gameinfo.cpp
blob6aac66cd170e5bcb99f1066829817bfdc469b692
1 /*
2 Copyright (c) 2006 Paolo Capriotti <p.capriotti@sns.it>
3 (c) 2006 Maurizio Monge <maurizio.monge@kdemail.net>
5 This program is free software; you can redistribute it and/or modify
6 it under the terms of the GNU General Public License as published by
7 the Free Software Foundation; either version 2 of the License, or
8 (at your option) any later version.
9 */
11 #include "gameinfo.h"
14 GameInfo::GameInfo(const Player& white, const Player& black,
15 const QString& rated, const QString& type,
16 int time, int increment)
17 : m_white(white)
18 , m_black(black)
19 , m_rated(rated)
20 , m_type(type)
21 , m_time(time)
22 , m_increment(increment)
23 , m_game_num(-1) {
24 m_variant = variantCode(m_type);
27 GameInfo::GameInfo(QRegExp& pattern, int offset)
28 : m_white(Player(pattern.cap(offset), pattern.cap(offset + 1).toInt()))
29 , m_black(Player(pattern.cap(offset + 2), pattern.cap(offset + 3).toInt()))
30 , m_rated(pattern.cap(offset + 4))
31 , m_type(pattern.cap(offset + 5))
32 , m_time(pattern.cap(offset + 6).toInt())
33 , m_increment(pattern.cap(offset + 7).toInt())
34 , m_game_num(-1) {
35 m_variant = variantCode(m_type);
38 QString GameInfo::variantCode(const QString& type) {
39 if (type == "blitz" || type == "standard" || type == "lightning"
40 || type == "untimed" || type == "chess")
41 return "Chess";
42 else if (type == "atomic")
43 return "Atomic";
44 else if (type == "crazyhouse")
45 return "Crazyhouse";
46 else
47 return "Dummy";