Browse Source

i seriously forgot what I did since last commit

master
myitinos 1 year ago
parent
commit
b35fad4086

+ 16
- 0
.vscode/c_cpp_properties.json View File

@@ -0,0 +1,16 @@
1
+{
2
+    "configurations": [
3
+        {
4
+            "name": "Linux",
5
+            "includePath": [
6
+                "${workspaceFolder}/**"
7
+            ],
8
+            "defines": [],
9
+            "compilerPath": "/usr/bin/gcc",
10
+            "cStandard": "c11",
11
+            "cppStandard": "c++17",
12
+            "intelliSenseMode": "clang-x64"
13
+        }
14
+    ],
15
+    "version": 4
16
+}

+ 7
- 0
.vscode/settings.json View File

@@ -0,0 +1,7 @@
1
+{
2
+    "files.associations": {
3
+        "limits": "cpp",
4
+        "type_traits": "cpp",
5
+        "ostream": "cpp"
6
+    }
7
+}

+ 12
- 0
.vscode/tasks.json View File

@@ -0,0 +1,12 @@
1
+{
2
+    // See https://go.microsoft.com/fwlink/?LinkId=733558
3
+    // for the documentation about the tasks.json format
4
+    "version": "2.0.0",
5
+    "tasks": [
6
+        {
7
+            "label": "echo",
8
+            "type": "shell",
9
+            "command": "echo Hello"
10
+        }
11
+    ]
12
+}

+ 44
- 0
Makefile View File

@@ -0,0 +1,44 @@
1
+COMPILER=g++
2
+#FLAGS=-g -I. -pedantic -Wall -Wextra -Wcast-align -Wcast-qual -Wctor-dtor-privacy -Wdisabled-optimization -Wformat=2 -Winit-self -Wlogical-op -Wmissing-declarations -Wmissing-include-dirs -Wnoexcept -Wold-style-cast -Woverloaded-virtual -Wredundant-decls -Wshadow -Wsign-conversion -Wsign-promo -Wstrict-null-sentinel -Wstrict-overflow=5 -Wswitch-default -Wundef -Werror -Wno-unused
3
+#FLAGS=-g -I.
4
+FLAGS=-I.
5
+O_DIR=obj
6
+
7
+CLASS_DIR=src/class
8
+INTER_DIR=src/interface
9
+SYS_DIR=src/system
10
+
11
+OBJ_CMD=$(COMPILER) $(FLAGS) -c $< -o $@
12
+
13
+.PHONY : clean
14
+
15
+version001 : main001.o character.o player.o monster.o creation.o info.o betatest.o
16
+	$(COMPILER) $(FLAGS) -o $@ \
17
+		main001.o \
18
+		character.o player.o   monster.o \
19
+		info.o      creation.o \
20
+		betatest.o
21
+
22
+main001.o : main001.cpp $(CLASS_DIR)/player.hpp $(INTER_DIR)/creation.hpp $(INTER_DIR)/info.hpp $(SYS_DIR)/betatest.hpp 
23
+	$(OBJ_CMD)
24
+
25
+character.o :  $(CLASS_DIR)/character.cpp $(CLASS_DIR)/character.hpp
26
+	$(OBJ_CMD)
27
+
28
+player.o : $(CLASS_DIR)/player.cpp $(CLASS_DIR)/player.hpp $(CLASS_DIR)/character.hpp
29
+	$(OBJ_CMD)
30
+
31
+monster.o : $(CLASS_DIR)/monster.cpp $(CLASS_DIR)/monster.hpp $(CLASS_DIR)/character.hpp
32
+	$(OBJ_CMD)
33
+
34
+creation.o : $(INTER_DIR)/creation.cpp $(INTER_DIR)/creation.hpp $(CLASS_DIR)/player.hpp $(INTER_DIR)/info.hpp
35
+	$(OBJ_CMD)
36
+
37
+info.o : $(INTER_DIR)/info.cpp $(INTER_DIR)/info.hpp $(CLASS_DIR)/player.hpp $(CLASS_DIR)/character.hpp $(CLASS_DIR)/monster.hpp 
38
+	$(OBJ_CMD)
39
+
40
+betatest.o : $(SYS_DIR)/betatest.cpp $(SYS_DIR)/betatest.hpp
41
+	$(OBJ_CMD)
42
+
43
+clean :
44
+	rm -f *.o

+ 1
- 1
README.md View File

@@ -5,4 +5,4 @@
5 5
 This repo depends on:
6 6
 
7 7
 ### cpp-base64
8
-here: https://github.com/ReneNyffenegger/cpp-base64
8
+here: https://github.com/ReneNyffenegger/cpp-base64

+ 1
- 0
beta.test View File

@@ -0,0 +1 @@
1
+GKSK{4re_Y0u_53ri0usly_checking_f0r_b3t4_t3sT?}

+ 0
- 95
class/character.hpp View File

@@ -1,95 +0,0 @@
1
-#ifndef _2EASY4ME_CHARACTER_H_
2
-#define _2EASY4ME_CHARACTER_H_
3
-
4
-#include <cstring>
5
-
6
-class Character
7
-{
8
-  protected:
9
-    char name[16];
10
-    int maxHp;
11
-    int hp;
12
-
13
-    int att;
14
-    int def;
15
-
16
-  public:
17
-    Character(char *name)
18
-    {
19
-        strncpy(this->name, name, sizeof(this->name));
20
-        this->maxHp = 100;
21
-        this->hp = 100;
22
-        this->att = 10;
23
-        this->def = 5;
24
-    }
25
-
26
-    Character(char *name, int hp, int att, int def)
27
-    {
28
-        strncpy(this->name, name, sizeof(this->name));
29
-        this->maxHp = hp;
30
-        this->hp = hp;
31
-        this->att = att;
32
-        this->def = def;
33
-    }
34
-
35
-    bool isDead()
36
-    {
37
-        return hp <= 0;
38
-    }
39
-
40
-    bool isAlive()
41
-    {
42
-        return hp > 0;
43
-    }
44
-
45
-    bool restoreHP()
46
-    {
47
-        this->hp = this->maxHp;
48
-    }
49
-
50
-    int checkHP()
51
-    {
52
-        return hp;
53
-    }
54
-
55
-    int getMaxHP()
56
-    {
57
-        return maxHp;
58
-    }
59
-
60
-    int getDef()
61
-    {
62
-        return def;
63
-    }
64
-
65
-    char *getName()
66
-    {
67
-        return name;
68
-    }
69
-
70
-    int getAtt()
71
-    {
72
-        return att;
73
-    }
74
-
75
-    int defend(int dmg)
76
-    {
77
-        dmg -= def;
78
-        if (dmg > 0)
79
-        {
80
-            hp -= dmg;
81
-            return dmg;
82
-        }
83
-        else
84
-        {
85
-            return 0;
86
-        }
87
-    }
88
-
89
-    int attack()
90
-    {
91
-        return att;
92
-    }
93
-};
94
-
95
-#endif

+ 0
- 36
class/monster.hpp View File

@@ -1,36 +0,0 @@
1
-#ifndef _2EASY4ME_MONSTER_H_
2
-#define _2EASY4ME_MONSTER_H_
3
-
4
-#include "character.hpp"
5
-
6
-class Monster : public Character
7
-{
8
-  protected:
9
-    int bounty;
10
-
11
-  public:
12
-    Monster(char *name)
13
-        : Character(name)
14
-    {
15
-        this->bounty = 0;
16
-    }
17
-
18
-    Monster(char *name, int hp, int att, int def)
19
-        : Character(name, hp, att, def)
20
-    {
21
-        this->bounty = 0;
22
-    }
23
-
24
-    Monster(char *name, int hp, int att, int def, int bounty)
25
-        : Character(name, hp, att, def)
26
-    {
27
-        this->bounty = bounty;
28
-    }
29
-
30
-    int drop()
31
-    {
32
-        return bounty;
33
-    }
34
-};
35
-
36
-#endif

+ 0
- 88
class/player.hpp View File

@@ -1,88 +0,0 @@
1
-#ifndef _2EASY4ME_PLAYER_H_
2
-#define _2EASY4ME_PLAYER_H_
3
-
4
-#include "character.hpp"
5
-
6
-#include "string.h"
7
-
8
-class Player : public Character
9
-{
10
-  protected:
11
-    int xp;
12
-    int level;
13
-
14
-  public:
15
-    Player(char *name)
16
-        : Character(name)
17
-    {
18
-        this->xp = 0;
19
-        this->level = 1;
20
-    }
21
-
22
-    Player(char *name, int hp, int att, int def, int level, int xp)
23
-        : Character(name, hp, att, def)
24
-    {
25
-        this->xp = xp;
26
-        this->level = level;
27
-    }
28
-
29
-    int getLevel()
30
-    {
31
-        return level;
32
-    }
33
-
34
-    bool checkLevelup()
35
-    {
36
-        return xp > (level * level);
37
-    }
38
-
39
-    bool levelUp(int stat)
40
-    {
41
-        switch (stat)
42
-        {
43
-        case 1:
44
-            hp += 10;
45
-            break;
46
-        case 2:
47
-            att += 2;
48
-            break;
49
-        case 3:
50
-            def += 1;
51
-            break;
52
-        }
53
-
54
-        xp -= level * level;
55
-    }
56
-
57
-    int generateCode(char *dst)
58
-    {
59
-        return sprintf(dst,
60
-                       "PlayerName:%15s;PlayerHp:%d;PlayerAtt:%d;PlayerDef:%d;PlayerLvl:%d;PlayerExp:%d;",
61
-                       this->name, this->hp, this->att, this->def, this->level, this->xp);
62
-    }
63
-
64
-    Player *loadCode(char *dst)
65
-    {
66
-        char name[16];
67
-        int hp;
68
-        int att;
69
-        int def;
70
-        int lvl;
71
-        int exp;
72
-
73
-        int result = sscanf(dst,
74
-                            "PlayerName:%15s;PlayerAtt:%d;PlayerDef:%d;PlayerLvl:%d;PlayerExp:%d;",
75
-                            name, &hp, &att, &def, &lvl, &exp);
76
-
77
-        if (result == 5)
78
-        {
79
-            return new Player(name, hp, att, def, lvl, exp);
80
-        }
81
-        else
82
-        {
83
-            return nullptr;
84
-        }
85
-    }
86
-};
87
-
88
-#endif

+ 1
- 0
cpp-base64

@@ -0,0 +1 @@
1
+Subproject commit 6420804f7ba10e8c3049c6e3b59ec88c88d808a6

+ 0
- 33
main.cpp View File

@@ -1,33 +0,0 @@
1
-#include <iostream>
2
-
3
-#include <cstring>
4
-#include <math.h>
5
-
6
-#include "cpp-base64/base64.h"
7
-#include "cpp-base64/base64.cpp"
8
-
9
-#include "class/monster.hpp"
10
-#include "class/player.hpp"
11
-
12
-Player* createNewPlayer()
13
-{
14
-    char name[16];
15
-
16
-    printf("Input character name (MAX 15): ");
17
-    scanf("%15s", name);
18
-
19
-    return new Player(name);
20
-}
21
-
22
-int main(int argc, char const *argv[])
23
-{
24
-    char name[16];
25
-
26
-    printf("Input name: ");
27
-    scanf("%15s", name);
28
-
29
-    Player *player = new Player(name);
30
-
31
-    printf("Created new player with name %s at %p\n", name, (void *)player);
32
-    return 0;
33
-}

+ 58
- 0
main001.cpp View File

@@ -0,0 +1,58 @@
1
+#include "src/class/player.hpp"
2
+#include "src/interface/creation.hpp"
3
+#include "src/interface/info.hpp"
4
+#include "src/system/betatest.hpp"
5
+
6
+#include <iostream>
7
+
8
+int main(int argc, char const *argv[])
9
+{
10
+    Player *player = nullptr;
11
+
12
+    if (checkBetaTest())
13
+    {
14
+        int choice;
15
+
16
+        do
17
+        {
18
+            printf("===== HackTheGame v0.0.1 (Beta) =====\n");
19
+            printf("[1] Create new Character\n");
20
+            printf("[2] Character Info\n");
21
+            printf("[9] Credits\n");
22
+            printf("[0] Exit\n");
23
+            printf(">");
24
+
25
+            scanf("%d", &choice);
26
+
27
+            switch (choice)
28
+            {
29
+            case 1:
30
+                player = createCharacter();
31
+                break;
32
+            case 2:
33
+                if (player == nullptr)
34
+                {
35
+                    std::cout << "Please create a character first!" << std::endl;
36
+                }
37
+                else
38
+                {
39
+                    Info::ofPlayer(player);
40
+                }
41
+                break;
42
+            case 9:
43
+                Info::ofApplication();
44
+                break;
45
+            case 0:
46
+                break;
47
+            default:
48
+                printf("Not Implemented...\n");
49
+            }
50
+
51
+        } while (choice != 0);
52
+    }
53
+    else
54
+    {
55
+        printf("Please get a beta.test key from one of our developer to get access to beta test...\n");
56
+        return 0;
57
+    }
58
+}

BIN
obj/betatest.o View File


BIN
obj/character001.o View File


BIN
obj/creation001.o View File


BIN
obj/info001.o View File


BIN
obj/main001.o View File


BIN
obj/player001.o View File


+ 1
- 0
peda-session-version001.txt View File

@@ -0,0 +1 @@
1
+

+ 73
- 0
src/class/character.cpp View File

@@ -0,0 +1,73 @@
1
+#include "src/class/character.hpp"
2
+
3
+Character::Character(std::string characterName)
4
+{
5
+    name = characterName;
6
+    maxHP = 100;
7
+    currentHP = 100;
8
+    atk = 10;
9
+    def = 5;
10
+}
11
+
12
+Character::Character(std::string characterName, int characterMaxHP, int characterAtk, int characterDef)
13
+{
14
+    name = characterName;
15
+    maxHP = characterMaxHP;
16
+    currentHP = maxHP;
17
+    atk = characterAtk;
18
+    def = characterDef;
19
+}
20
+
21
+bool Character::isDead()
22
+{
23
+    return currentHP <= 0;
24
+}
25
+
26
+bool Character::isAlive()
27
+{
28
+    return currentHP > 0;
29
+}
30
+
31
+std::string Character::getName()
32
+{
33
+    return name;
34
+}
35
+
36
+void Character::restoreHP()
37
+{
38
+    currentHP = maxHP;
39
+}
40
+
41
+int Character::getCurrentHP()
42
+{
43
+    return currentHP;
44
+}
45
+
46
+int Character::getMaxHP()
47
+{
48
+    return maxHP;
49
+}
50
+
51
+int Character::getDef()
52
+{
53
+    return def;
54
+}
55
+
56
+int Character::getAtk()
57
+{
58
+    return atk;
59
+}
60
+
61
+int Character::defend(int dmg)
62
+{
63
+    int cleanDamage = dmg - def;
64
+    if (cleanDamage <= 0)
65
+    {
66
+        return 0;
67
+    }
68
+    else
69
+    {
70
+        currentHP = currentHP - cleanDamage;
71
+        return cleanDamage;
72
+    }
73
+}

+ 36
- 0
src/class/character.hpp View File

@@ -0,0 +1,36 @@
1
+#ifndef HACKTHEGAME_CHARACTER_HPP
2
+#define HACKTHEGAME_CHARACTER_HPP
3
+
4
+#include <string>
5
+
6
+class Character
7
+{
8
+  protected:
9
+    std::string name;
10
+
11
+    int maxHP;
12
+    int currentHP;
13
+
14
+    int atk;
15
+    int def;
16
+
17
+  public:
18
+    Character(std::string characterName);
19
+    Character(std::string characterName, int characterMaxHP, int characterAtk, int characterDef);
20
+
21
+    bool isDead();
22
+    bool isAlive();
23
+
24
+    std::string getName();
25
+
26
+    void restoreHP();
27
+    int getCurrentHP();
28
+    int getMaxHP();
29
+
30
+    int getDef();
31
+    int getAtk();
32
+
33
+    int defend(int dmg);
34
+};
35
+
36
+#endif

+ 24
- 0
src/class/monster.cpp View File

@@ -0,0 +1,24 @@
1
+#include "src/class/monster.hpp"
2
+
3
+Monster::Monster(std::string monsterName)
4
+    : Character(monsterName)
5
+{
6
+    bounty = 0;
7
+}
8
+
9
+Monster::Monster(std::string monsterName, int monsterMaxHP, int monsterAtk, int monsterDef)
10
+    : Character(monsterName, monsterMaxHP, monsterAtk, monsterDef)
11
+{
12
+    bounty = 0;
13
+}
14
+
15
+Monster::Monster(std::string monsterName, int monsterMaxHP, int monsterAtk, int monsterDef, int monsterBounty)
16
+    : Character(monsterName, monsterMaxHP, monsterAtk, monsterDef)
17
+{
18
+    bounty = monsterBounty;
19
+}
20
+
21
+int Monster::getBounty()
22
+{
23
+    return bounty;
24
+}

+ 19
- 0
src/class/monster.hpp View File

@@ -0,0 +1,19 @@
1
+#ifndef HACKTHEGAME_MONSTER_HPP
2
+#define HACKTHEGAME_MONSTER_HPP
3
+
4
+#include "src/class/character.hpp"
5
+
6
+class Monster : public Character
7
+{
8
+  protected:
9
+    int bounty;
10
+
11
+  public:
12
+    Monster(std::string monsterName);
13
+    Monster(std::string monsterName, int monsterMaxHP, int monsterAtk, int monsterDef);
14
+    Monster(std::string monsterName, int monsterMaxHP, int monsterAtk, int monsterDef, int monsterBounty);
15
+    
16
+    int getBounty();
17
+};
18
+
19
+#endif

+ 81
- 0
src/class/player.cpp View File

@@ -0,0 +1,81 @@
1
+#include "src/class/player.hpp"
2
+
3
+#include <string.h>
4
+
5
+Player::Player(std::string playerName)
6
+    : Character(playerName)
7
+{
8
+    experience = 0;
9
+    level = 1;
10
+}
11
+
12
+Player::Player(std::string playerName, int playerMaxHP, int playerAtk, int playerDef, int playerLevel, int playerExp)
13
+    : Character(playerName, playerMaxHP, playerAtk, playerDef)
14
+{
15
+    experience = playerExp;
16
+    level = playerLevel;
17
+}
18
+
19
+int Player::getLevel()
20
+{
21
+    return level;
22
+}
23
+
24
+int Player::getExp()
25
+{
26
+    return experience;
27
+}
28
+
29
+int Player::expToLevelUp()
30
+{
31
+    if (level >= PLAYER_MAX_LEVEL)
32
+    {
33
+        return 0;
34
+    }
35
+    else
36
+    {
37
+        return (level * level) - experience;
38
+    }
39
+}
40
+
41
+bool Player::checkLevelup()
42
+{
43
+    return expToLevelUp() < 0;
44
+}
45
+
46
+bool Player::levelUp(int stat)
47
+{
48
+    if (checkLevelup())
49
+    {
50
+        switch (stat)
51
+        {
52
+        case 1:
53
+            maxHP += 10;
54
+            restoreHP();
55
+            break;
56
+        case 2:
57
+            atk += 2;
58
+            break;
59
+        case 3:
60
+            def += 1;
61
+            break;
62
+        }
63
+        return true;
64
+    }
65
+    else
66
+    {
67
+        return false;
68
+    }
69
+}
70
+
71
+int Player::takeExperience(int bounty)
72
+{
73
+    experience = experience + bounty;
74
+
75
+    if (experience > PLAYER_MAX_EXPERIENCE)
76
+    {
77
+        experience = PLAYER_MAX_EXPERIENCE;
78
+    }
79
+
80
+    return experience;
81
+}

+ 28
- 0
src/class/player.hpp View File

@@ -0,0 +1,28 @@
1
+#ifndef HACKTHEGAME_PLAYER_HPP
2
+#define HACKTHEGAME_PLAYER_HPP
3
+
4
+#define PLAYER_MAX_LEVEL 1000
5
+#define PLAYER_MAX_EXPERIENCE 9999999
6
+
7
+#include "src/class/character.hpp"
8
+
9
+class Player : public Character
10
+{
11
+  protected:
12
+    int experience;
13
+    int level;
14
+
15
+  public:
16
+    Player(std::string playerName);
17
+    Player(std::string playerName, int playerMaxHP, int playerAtt, int playerDef, int playerLevel, int playerExp);
18
+
19
+    int getLevel();
20
+    int getExp();
21
+    int expToLevelUp();
22
+    int takeExperience(int drop);
23
+
24
+    bool checkLevelup();
25
+    bool levelUp(int stat);
26
+};
27
+
28
+#endif

system/battle0.hpp → src/interface/battle0.cpp View File

@@ -1,20 +1,16 @@
1
-#ifndef _2EASY4ME_BATTLE_SYSTEM_LEVEL0_
2
-#define _2EASY4ME_BATTLE_SYSTEM_LEVEL0_
3
-
4
-#include "../class/monster.hpp"
5
-#include "../class/player.hpp"
6
-
7
-#include <cstdio>
1
+#include "src/interface/battle0.hpp"
8 2
 
9 3
 int startBattle(Player *player, Monster *monster)
10 4
 {
11 5
     printf(" ===== BATTLE INFO  ===== \n");
6
+
12 7
     printf("%15s (Lv.%n):\n", player->getName(), player->getLevel());
13
-    printf("  HP : %n/%n\n", player->checkHP(), player->getMaxHP());
8
+    printf("  HP : %n/%n\n", player->getCurrentHP(), player->getMaxHP());
14 9
     printf("  Att: %n\n", player->getAtt());
15 10
     printf("  Def: %n\n", player->getDef());
11
+
16 12
     printf("%15s:\n", monster->getName());
17
-    printf("  HP : %n/%n\n", monster->checkHP(), monster->getMaxHP());
13
+    printf("  HP : %n/%n\n", monster->getCurrentHP(), monster->getMaxHP());
18 14
     printf("  Att: %n\n", monster->getAtt());
19 15
     printf("  Def: %n\n", monster->getDef());
20 16
 
@@ -38,6 +34,4 @@ int startBattle(Player *player, Monster *monster)
38 34
         printf("YOU LOSE !!!\n");
39 35
         return 0;
40 36
     }
41
-}
42
-
43
-#endif
37
+}

+ 11
- 0
src/interface/battle0.hpp View File

@@ -0,0 +1,11 @@
1
+#ifndef HACKTHEGAME_BATTLESYSTEM_VERSION_000_HPP
2
+#define HACKTHEGAME_BATTLESYSTEM_VERSION_000_HPP
3
+
4
+#include "src/class/monster.hpp"
5
+#include "src/class/player.hpp"
6
+
7
+#include <cstdio>
8
+
9
+int startBattle(Player *player, Monster *monster);
10
+
11
+#endif

+ 43
- 0
src/interface/creation.cpp View File

@@ -0,0 +1,43 @@
1
+#include "src/interface/creation.hpp"
2
+#include "src/interface/info.hpp"
3
+
4
+#include <iostream>
5
+
6
+Player *createCharacter()
7
+{
8
+    std::string name;
9
+
10
+    char choice;
11
+
12
+    Player *newPlayer = new Player("HackTheGame");
13
+
14
+    std::cout << "Welcome to character creation !!!" << std::endl;
15
+
16
+    do
17
+    {
18
+        std::cout << "Please enter your character name: (Max 15 letters)\n"
19
+                  << "> " << std::flush;
20
+
21
+        std::cin >> name;
22
+        if (name.size() > 15)
23
+        {
24
+            std::cout << "Your name is too long!" << std::endl;
25
+            continue;
26
+        }
27
+
28
+        std::cout << "Creating your character..." << std::endl;
29
+
30
+        delete newPlayer;
31
+        newPlayer = new Player(name);
32
+
33
+        std::cout << "Done...\n"
34
+                  << "Character Info: " << std::endl;
35
+
36
+        Info::ofCharacter(newPlayer);
37
+
38
+        std::cout << "Accept (y/N)?: " << std::flush;
39
+        std::cin >> choice;
40
+    } while (choice != 'Y' && choice != 'y');
41
+
42
+    return newPlayer;
43
+}

+ 9
- 0
src/interface/creation.hpp View File

@@ -0,0 +1,9 @@
1
+#ifndef HACKTHEGAME_CHARACTER_CREATION_HPP
2
+#define HACKTHEGAME_CHARACTER_CREATION_HPP
3
+
4
+#include "src/class/player.hpp"
5
+#include "src/class/monster.hpp"
6
+
7
+Player *createCharacter();
8
+
9
+#endif

+ 49
- 0
src/interface/info.cpp View File

@@ -0,0 +1,49 @@
1
+#include "src/interface/info.hpp"
2
+
3
+#include <iostream>
4
+
5
+void Info::ofCharacter(Character *character)
6
+{
7
+    std::cout << "Name: " << character->getName() << "\n"
8
+              << "  HP : " << character->getCurrentHP() << "/" << character->getMaxHP() << "\n"
9
+              << "  Atk: " << character->getAtk() << "\n"
10
+              << "  Def: " << character->getDef() << std::endl;
11
+}
12
+
13
+void Info::ofPlayer(Player *player)
14
+{
15
+    std::cout << "Name: " << player->getName() << "\n"
16
+              << "  Lvl: " << player->getLevel() << "\n"
17
+              << "    Experience: " << player->getExp() << "\n"
18
+              << "    to LevelUp: " << player->expToLevelUp() << "\n"
19
+              << "  HP : " << player->getCurrentHP() << "/" << player->getMaxHP() << "\n"
20
+              << "  Atk: " << player->getAtk() << "\n"
21
+              << "  Def: " << player->getDef() << std::endl;
22
+}
23
+
24
+void Info::ofMonster(Monster *monster)
25
+{
26
+    std::cout << "Name: " << monster->getName() << "\n"
27
+              << "  HP : " << monster->getCurrentHP() << "/" << monster->getMaxHP() << "\n"
28
+              << "  Atk: " << monster->getAtk() << "\n"
29
+              << "  Def: " << monster->getDef() << "\n"
30
+              << "  Lvl: " << monster->getBounty() << std::endl;
31
+}
32
+
33
+void Info::ofApplication()
34
+{
35
+    std::cout << "=================================\n"
36
+              << "========== HackTheGame ==========\n"
37
+              << "=================================\n"
38
+              << "This stupid app is developed for \n"
39
+              << "CTF @GKSK2019 that was held on   \n"
40
+              << "16 Feb 2019 as a playground for  \n"
41
+              << "Kelompok Studi Linux Members of  \n"
42
+              << "STMIK STIKOM Bali->              \n"
43
+              << "Developed by:                    \n"
44
+              << "   myitinos                      \n"
45
+              << "                                 \n"
46
+              << "Thanks for Playing !!!           \n"
47
+              << "=================================\n"
48
+              << std::endl;
49
+}

+ 21
- 0
src/interface/info.hpp View File

@@ -0,0 +1,21 @@
1
+#ifndef HACKTHEGAME_CHARACTER_INFO_HPP
2
+#define HACKTHEGAME_CHARACTER_INFO_HPP
3
+
4
+#include "src/class/character.hpp"
5
+#include "src/class/monster.hpp"
6
+#include "src/class/player.hpp"
7
+
8
+class Info
9
+{
10
+  private:
11
+    Info(){};
12
+
13
+  public:
14
+    static void ofCharacter(Character *);
15
+    static void ofPlayer(Player *);
16
+    static void ofMonster(Monster *);
17
+
18
+    static void ofApplication();
19
+};
20
+
21
+#endif

+ 29
- 0
src/system/betatest.cpp View File

@@ -0,0 +1,29 @@
1
+#include "src/system/betatest.hpp"
2
+
3
+#include <fstream>
4
+#include <string>
5
+
6
+bool checkBetaTest()
7
+{
8
+    std::string betaFlag = "4re_Y0u_53ri0usly_checking_f0r_b3t4_t3sT?";
9
+    std::string tmp;
10
+
11
+    int result = -1;
12
+    
13
+    try
14
+    {
15
+        std::fstream betaFile("beta.test");
16
+
17
+        if (betaFile) {
18
+            betaFile >> tmp;
19
+
20
+            result = tmp.compare("GKSK{" + betaFlag + "}");
21
+        }
22
+    }
23
+    catch(...)
24
+    {
25
+        return false;
26
+    }
27
+
28
+    return result == 0;
29
+}

+ 6
- 0
src/system/betatest.hpp View File

@@ -0,0 +1,6 @@
1
+#ifndef HACKTHEGAME_BETATEST_HPP
2
+#define HACKTHEGAME_BETATEST_HPP
3
+
4
+bool checkBetaTest();
5
+
6
+#endif

BIN
version001 View File


Loading…
Cancel
Save