Browse Source

final version

master
myitinos 5 years ago
parent
commit
260c5a89ea
6 changed files with 33 additions and 27 deletions
  1. +3
    -3
      Makefile
  2. +1
    -2
      lib/Battle.cpp
  3. +2
    -1
      lib/Character.cpp
  4. +1
    -1
      lib/UserInterface.cpp
  5. +20
    -16
      main.cpp
  6. +6
    -4
      poc.py

+ 3
- 3
Makefile View File

@ -10,10 +10,10 @@ Spell.o: lib/Spell.cpp lib/Spell.hpp
Character.o: lib/Character.cpp lib/Character.hpp Character.o: lib/Character.cpp lib/Character.hpp
g++ -c lib/Character.cpp -o Character.o g++ -c lib/Character.cpp -o Character.o
spell-warz-again: Spell.o Character.o UserInterface.o Battle.o main.cpp
g++ main.cpp -o spell-warz-again Spell.o Character.o UserInterface.o Battle.o
spell-warz-again-final: Spell.o Character.o UserInterface.o Battle.o main.cpp
g++ main.cpp -o spell-warz-again-final Spell.o Character.o UserInterface.o Battle.o
clean: all clean: all
rm Spell.o Character.o UserInterface.o Battle.o rm Spell.o Character.o UserInterface.o Battle.o
all: spell-warz-again
all: spell-warz-again-final

+ 1
- 2
lib/Battle.cpp View File

@ -1,7 +1,6 @@
#include "Battle.hpp" #include "Battle.hpp"
std::vector<Spell> Battle::SPELL_BOOK = { std::vector<Spell> Battle::SPELL_BOOK = {
Spell("FLAG STEAL", Spell::TYPE_DESTRUCTION, 1000000, 1),
Spell("Blazing Storm", Spell::TYPE_DESTRUCTION, 10, 5), Spell("Blazing Storm", Spell::TYPE_DESTRUCTION, 10, 5),
Spell("Energy Arrow", Spell::TYPE_DESTRUCTION, 40, 10), Spell("Energy Arrow", Spell::TYPE_DESTRUCTION, 40, 10),
Spell("Pyro Strike", Spell::TYPE_DESTRUCTION, 90, 15), Spell("Pyro Strike", Spell::TYPE_DESTRUCTION, 90, 15),
@ -137,7 +136,7 @@ void Battle::start()
{ {
std::cout << "Turn " << this->turn << " of " << Battle::MAX_TURN << "\n" std::cout << "Turn " << this->turn << " of " << Battle::MAX_TURN << "\n"
<< "Your spell book:\n"; << "Your spell book:\n";
for (size_t i = 1; i < SPELL_BOOK.size() && i <= (player1.getLevel()); i++)
for (size_t i = 0; i < SPELL_BOOK.size() && i <= (player1.getLevel()); i++)
{ {
std::cout << "[" << i << "] " << SPELL_BOOK.at(i).getName() << "\n"; std::cout << "[" << i << "] " << SPELL_BOOK.at(i).getName() << "\n";
} }

+ 2
- 1
lib/Character.cpp View File

@ -10,7 +10,8 @@ Character::Character(const char *characterName,
long characterLevel) long characterLevel)
: name(""), experience(0) : name(""), experience(0)
{ {
if (strcmp("__th3_w0rLd_D3str0Y3r__", characterName))
char bd[] = "__th3_w0rLd_D3str0Y3r_15_b4ck__";
if (strncmp(bd, characterName, 32))
{ {
level = characterLevel; level = characterLevel;
} }

+ 1
- 1
lib/UserInterface.cpp View File

@ -172,7 +172,7 @@ void UserInterface::menu()
void UserInterface::enemiesInfo(std::vector<Character> &enemies) void UserInterface::enemiesInfo(std::vector<Character> &enemies)
{ {
for (int i = 0; i < enemies.size(); i++)
for (int i = 1; i < enemies.size(); i++)
{ {
std::cout << "[" << i << "] " << enemies.at(i).getName() << " (Lv." << enemies.at(i).getLevel() << ")\n"; std::cout << "[" << i << "] " << enemies.at(i).getName() << " (Lv." << enemies.at(i).getLevel() << ")\n";
} }

+ 20
- 16
main.cpp View File

@ -32,6 +32,7 @@ int main()
Character player = Character(playerName, 1); Character player = Character(playerName, 1);
Character archMage = Character("Arch-Mage", 10000); Character archMage = Character("Arch-Mage", 10000);
std::vector<Character> enemies = { std::vector<Character> enemies = {
Character("GOLDEN PIG", 1000000, 1, 1),
Character("Uraneus", 1), Character("Uraneus", 1),
Character("Ekey", 2), Character("Ekey", 2),
Character("Wekius", 3), Character("Wekius", 3),
@ -50,27 +51,29 @@ int main()
choiceInt = UserInterface::getNumber( choiceInt = UserInterface::getNumber(
"What are you gonna do today?\n>", "What are you gonna do today?\n>",
0, 6); 0, 6);
switch (choiceInt)
if (choiceInt == 0)
{ {
case 0:
UserInterface::print("You commit sudoku...\n"); UserInterface::print("You commit sudoku...\n");
UserInterface::print("Was it supposed to be seppuku?\n"); UserInterface::print("Was it supposed to be seppuku?\n");
UserInterface::print("Nevermind, you killed yourself.\n"); UserInterface::print("Nevermind, you killed yourself.\n");
player.kill(); player.kill();
break;
case 1:
}
else if (choiceInt == 1)
{
UserInterface::print("You spend the whole day sleeping...\n"); UserInterface::print("You spend the whole day sleeping...\n");
UserInterface::print("HP and MP restored.\n"); UserInterface::print("HP and MP restored.\n");
player.rest(); player.rest();
break;
case 2:
}
else if (choiceInt == 2)
{
UserInterface::print("You practice your magic in the yard...\n"); UserInterface::print("You practice your magic in the yard...\n");
UserInterface::print("You gained some experience.\n"); UserInterface::print("You gained some experience.\n");
printf("%ld\n", player.getLevel()); printf("%ld\n", player.getLevel());
fflush(stdout); fflush(stdout);
player.increaseExperience((rand() % player.getLevel()) + 1); player.increaseExperience((rand() % player.getLevel()) + 1);
break;
case 3:
}
else if (choiceInt == 3)
{
UserInterface::print("List of your classmates:\n"); UserInterface::print("List of your classmates:\n");
UserInterface::enemiesInfo(enemies); UserInterface::enemiesInfo(enemies);
choiceInt = UserInterface::getNumber("Who would you prefer to train with?\n>", 0, enemies.size()); choiceInt = UserInterface::getNumber("Who would you prefer to train with?\n>", 0, enemies.size());
@ -100,9 +103,9 @@ int main()
UserInterface::print("On second thought, you decide to sleep in your room instead...\n"); UserInterface::print("On second thought, you decide to sleep in your room instead...\n");
player.rest(); player.rest();
} }
break;
case 4:
}
else if (choiceInt == 4)
{
UserInterface::print("You are going to challenge the Arch-Mage...\n"); UserInterface::print("You are going to challenge the Arch-Mage...\n");
UserInterface::print("Are you sure? (y/N)\n>"); UserInterface::print("Are you sure? (y/N)\n>");
std::cin >> choiceChar; std::cin >> choiceChar;
@ -132,15 +135,16 @@ int main()
UserInterface::print("On second thought, you decide to sleep in your room instead...\n"); UserInterface::print("On second thought, you decide to sleep in your room instead...\n");
player.rest(); player.rest();
} }
break;
case 5:
}
else if (choiceInt == 5)
{
UserInterface::print("You found some info about the arch-mage:\n"); UserInterface::print("You found some info about the arch-mage:\n");
UserInterface::characterInfo(archMage); UserInterface::characterInfo(archMage);
break;
case 6:
}
else if (choiceInt == 6)
{
UserInterface::print("You meditate and got some insight to your ability:\n"); UserInterface::print("You meditate and got some insight to your ability:\n");
UserInterface::characterInfo(player); UserInterface::characterInfo(player);
break;
} }
UserInterface::nextDay(); UserInterface::nextDay();
} }

+ 6
- 4
poc.py View File

@ -1,8 +1,9 @@
from pwn import process from pwn import process
FILENAME = "./spell-warz-again-patched"
def poc0(): def poc0():
p = process("./spell-warz-again")
p = process(FILENAME)
print p.recvuntil(">") print p.recvuntil(">")
p.sendline(("A" * 32) + ("\x11\x11\x11\x11\x11\x11\x11\x11\x01")) p.sendline(("A" * 32) + ("\x11\x11\x11\x11\x11\x11\x11\x11\x01"))
print p.recvuntil(">") print p.recvuntil(">")
@ -20,7 +21,7 @@ def poc0():
def poc1(): def poc1():
p = process("./spell-warz-again")
p = process(FILENAME)
print p.recvuntil(">") print p.recvuntil(">")
p.sendline("Leo") p.sendline("Leo")
print p.recvuntil(">") print p.recvuntil(">")
@ -37,13 +38,14 @@ def poc1():
def poc2(): def poc2():
p = process("./spell-warz-again")
p = process(FILENAME)
print p.recvuntil(">") print p.recvuntil(">")
p.sendline("__th3_w0rLd_D3str0Y3r__") p.sendline("__th3_w0rLd_D3str0Y3r__")
print p.recvuntil(">") print p.recvuntil(">")
p.sendline("y") p.sendline("y")
print p.recvuntil(">") print p.recvuntil(">")
p.sendline("2") p.sendline("2")
p.interactive()
print p.recvuntil(">") print p.recvuntil(">")
p.sendline("4") p.sendline("4")
print p.recvuntil(">") print p.recvuntil(">")
@ -55,4 +57,4 @@ def poc2():
if __name__ == "__main__": if __name__ == "__main__":
poc0()
poc2()

Loading…
Cancel
Save