Permalink
Cannot retrieve contributors at this time
Name already in use
A tag already exists with the provided branch name. Many Git commands accept both tag and branch names, so creating this branch may cause unexpected behavior. Are you sure you want to create this branch?
ASCII_Game_Project/battle.cpp
Go to fileThis commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
134 lines (63 sloc)
1.87 KB
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#include "demons.h" | |
#include "enemy.h" | |
#include <windows.h> | |
#include <stdlib.h> | |
#include<iostream> | |
#include <vector> | |
#include <string> | |
#include <cstdlib> | |
void battle() { | |
Enemy enemy1("1", "Pixie", "Fairy", "Neutral", 2, 3, 6, 4, 2, 7, "upbeat", false); | |
Demon party1 = create_demon(2); | |
int party1_hp = party1.battle_HP; | |
// the sound and music can only be played on Windows OS | |
bool playedbattlestart = PlaySound(TEXT("battlestart.wav"), NULL, SND_SYNC); | |
bool playedbattle =PlaySound(TEXT("battle.wav"), NULL,SND_FILENAME|SND_LOOP|SND_ASYNC); | |
// Meguro, S 2003. Normal Battle. Shoji Meguro. Shin Megami Tensei III: Nocturne Original Soundtrack. [CD]. Japan: ATLUS. | |
while (true) { | |
int a; | |
int command; | |
party1.print_name(); | |
std::cout << "\nHP: " << party1.battle_HP << std::endl; | |
enemy1.print_name(); | |
std::cout << std::endl << "HP: " << enemy1.battle_HP << std::endl; | |
std::cout << "1. Battle\n2. Negotiate\n"; | |
std::cin >> command; | |
std::cout << std::endl; | |
if(command == 1){ | |
int battle_command; | |
std::cout << "1.Zio\n2.Lunge\n"; | |
std::cin >> battle_command; | |
if (battle_command == 1) { | |
party1.magic_skill("Zio", 30); | |
party1.inflict_damage(&enemy1); | |
} | |
else if (battle_command == 2) { | |
party1.phys_skill("Lunge", 41); | |
party1.inflict_damage(&enemy1); | |
} | |
} | |
else if(command ==2){ | |
std::string flag; | |
enemy1.negotiate(); | |
if (enemy1.friendly == true) { | |
break; | |
} | |
} | |
if (enemy1.battle_HP <= 0) { | |
enemy1.print_name(); | |
std::cout << " is defeated." << std::endl; | |
break; | |
} | |
enemy1.print_name(); | |
std::cout << " attacks!" << std::endl; | |
enemy1.normal_attack(); | |
enemy1.inflict_damage(&party1); | |
std::cin >> a; | |
system("CLS"); | |
} | |
std::cout << "The battle has ended!" << std::endl; | |
int a; | |
std::cin >> a; | |
system("CLS"); | |
} |