freg  0.3
Free-Roaming Elementary Game
 All Classes Files Functions Variables Typedefs Enumerations Enumerator Macros Pages
Armour.cpp
Go to the documentation of this file.
1  /* freg, Free-Roaming Elementary Game with open and interactive world
2  * Copyright (C) 2012-2014 Alexander 'mmaulwurff' Kromm
3  * mmaulwurff@gmail.com
4  *
5  * This file is part of FREG.
6  *
7  * FREG is free software: you can redistribute it and/or modify
8  * it under the terms of the GNU General Public License as published by
9  * the Free Software Foundation, either version 3 of the License, or
10  * (at your option) any later version.
11  *
12  * FREG is distributed in the hope that it will be useful,
13  * but WITHOUT ANY WARRANTY; without even the implied warranty of
14  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15  * GNU General Public License for more details.
16  *
17  * You should have received a copy of the GNU General Public License
18  * along with FREG. If not, see <http://www.gnu.org/licenses/>. */
19 
20 #include "blocks/Armour.h"
21 
22 const int TRESHOLD = 10;
23 
24 // Armour section
25  void Armour::Damage(const int dmg, const int dmg_kind) {
26  if ( dmg > TRESHOLD ) {
27  Block::Damage(dmg/((Kind() == ARMOUR) ? 4 : 2), dmg_kind);
28  }
29  }
30 
31  int Armour::DamageLevel() const { return 0; }
33 
34  QString Armour::FullName() const {
35  return QObject::tr("Body armour (%1)").arg(SubName(Sub()));
36  }
37 
38 // Helmet section
40 
41  QString Helmet::FullName() const {
42  return QObject::tr("Helmet (%1)").arg(SubName(Sub()));
43  }
44 
45 // Boots section
47 
48  QString Boots::FullName() const {
49  return QObject::tr("Boots (%1)").arg(SubName(Sub()));
50  }
static QString SubName(int sub)
Returns translated substance name.
Definition: Block.cpp:69
wearable Wearable() const override
Definition: Armour.cpp:32
virtual void Damage(int dmg, int dmg_kind)
Definition: Block.cpp:117
QString FullName() const override
Definition: Armour.cpp:41
int DamageLevel() const override
Definition: Armour.cpp:31
QString FullName() const override
Definition: Armour.cpp:34
27
Definition: header.h:142
QString FullName() const override
Definition: Armour.cpp:48
wearable Wearable() const override
Definition: Armour.cpp:46
wearable Wearable() const override
Definition: Armour.cpp:39
int Kind() const
Definition: Block.h:145
int Sub() const
Definition: Block.h:144
wearable
Definition: Block.h:28
const int TRESHOLD
Definition: Armour.cpp:22
void Damage(int dmg, int dmg_kind) override
Definition: Armour.cpp:25