Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Binary file modified .DS_Store
Binary file not shown.
Binary file modified sem2/.DS_Store
Binary file not shown.
Binary file added sem2/SemischastnovKS/.DS_Store
Binary file not shown.
141 changes: 141 additions & 0 deletions sem2/SemischastnovKS/DinoWarsSFML/Converters.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,141 @@
#pragma once
#include <iostream>


std::string charToFName(char n) {
switch (n) {
case 'b':
return "brachi-2.png";
case 'd':
return "diplo-2.png";
case 's':
return "stego-2.png";
case 'r':
return "rex-2.png";
case 't':
return "trice-2.png";
default:
return "";
}
}

std::string toFName(int n) {
switch (n) {
case 0:
return "brachi.png";
case 1:
return "diplo.png";
case 2:
return "stego.png";
case 3:
return "rex.png";
case 4:
return "trice.png";
default:
return "";
}
}

std::string toName(int n) {
switch (n) {
case 0:
return "Brachiosaurus";
case 1:
return "Diplodocus";
case 2:
return "Stegosaurus";
case 3:
return "Tyrannosaurus";
case 4:
return "Triceratops";
default:
return "";
}
}

std::string toCost(int n) {
switch (n) {
case 0:
return "184";
case 1:
return "174";
case 2:
return "184";
case 3:
return "184";
case 4:
return "146";
default:
return "";
}
}

std::string toSTR(int n) {
switch (n) {
case 0:
return "STR: 15";
case 1:
return "STR: 20";
case 2:
return "STR: 15";
case 3:
return "STR: 30";
case 4:
return "STR: 20";
default:
return "";
}
}

std::string toINT(int n) {
switch (n) {
case 0:
return "INT: 30";
case 1:
return "INT: 24";
case 2:
return "INT: 12";
case 3:
return "INT: 12";
case 4:
return "INT: 15";
default:
return "";
}
}

std::string toDEX(int n) {
switch (n) {
case 0:
return "DEX: 12";
case 1:
return "DEX: 17";
case 2:
return "DEX: 30";
case 3:
return "DEX: 15";
case 4:
return "DEX: 18";
default:
return "";
}
}

std::string toInfo(char n) {
switch (n) {
case 't':
return "Triceratops STR: 20 DEX: 18 INT: 15";
case 'r':
return "Tyrannosaur STR: 30 DEX: 15 INT: 12";
case 's':
return "Stegosaurus STR: 15 DEX: 30 INT: 12";
case 'd':
return "Diplodocus STR: 20 DEX: 17 INT: 24";
case 'b':
return "Brachiosaurus STR: 15 DEX: 12 INT: 30";
case 'n':
return "";
default:
return "NAME_DISPLAY_ERROR";
}
}
71 changes: 71 additions & 0 deletions sem2/SemischastnovKS/DinoWarsSFML/Dino.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,71 @@
#pragma once

#include <iostream>


class Dino {
protected:
int STR;
int DEX;
int INT;
std::string name;
public:
virtual int damage(std::string terrain) = 0;
virtual void setSTR(int num){
STR = num;
}
virtual void setDEX(int num){
DEX = num;
}
virtual void setINT(int num){
INT = num;
}
virtual void setName(const std::string &dinoName) {
name = dinoName;
}
};

class DinoStr: public Dino {
public:
int damage(std::string terrain) override {
if (terrain == "plain") {
return 2 * STR;
}
else if (terrain == "river") {
return DEX;
}
else {
return INT;
}
}
};

class DinoDex: public Dino {
public:
int damage(std::string terrain) override {
if (terrain == "plain") {
return STR;
}
else if (terrain == "river") {
return 2 * DEX;
}
else {
return INT;
}
}
};

class DinoInt: public Dino {
public:
int damage(std::string terrain) override {
if (terrain == "plain") {
return STR;
}
else if (terrain == "river") {
return DEX;
}
else {
return 2 * INT;
}
}
};
38 changes: 38 additions & 0 deletions sem2/SemischastnovKS/DinoWarsSFML/Player.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
#pragma once

#include <iostream>
#include <vector>

class Player {
private:
std::vector<char> dinoList{'t', 'r', 'n'};
int money = 100;
int hp = 0;
public:
void setMoney(int m) {
money = m;
}
void setList(int pos, char name) {
dinoList[pos] = name;
}
void setHP(int n) {
hp = n;
}

int getMoney() const {
return money;
}
char getList(int pos) {
return dinoList[pos];
}
int getHP() const {
return hp;
}

void buyDino(int cost, char name, int pos) {
if (money >= cost) {
money -= cost;
dinoList[pos] = name;
}
}
};
Loading