// types.hpp
#pragma once
#include <iostream>
#include <vector>
#include <windows.h>
#include <string>
namespace Engine
{
namespace Core
{
class Bank;
class Player;
class Account;
class Game;
namespace Types
{
// typedef struct transaction
// {
// Player *sender;
// Player *reciever;
// int amount;
// } Transaction;
}
class Player
{
public:
int id;
std::string name;
Account account;
Player(std::string name, int id);
void displayInfo();
};
class Game
{
public:
std::vector<Player> allPlayers;
int playersCount = 0;
// void startGame();
void addPlayer(Player player);
Player createPlayer(int id);
};
class Bank
{
int reserve;
public:
Bank();
};
class Account
{
Player *holder;
int balance;
public:
Account();
int retrieveBalance();
int transferFund(Player *reciever, int amount);
int fundAccount(int amount = 0);
// std::vector<Types::Transaction> getTransactionLog();
};
}
namespace IO
{
namespace Types
{
enum Color
{
Gray = 8,
Blue = 9,
Green = 10,
Cyan = 11,
Red = 12,
Magenta = 13,
Yellow = 14,
White = 15,
};
enum KeyCode
{
KeyUp = 72,
KeyDown = 80,
Quit = 3,
};
}
class Console
{
HANDLE outHandle;
COORD cursorPosition = COORD{0, 0};
CONSOLE_SCREEN_BUFFER_INFO screenInfo;
CONSOLE_CURSOR_INFO cursorInfo;
public:
Console();
COORD getCursorPosition();
void setCursorPosition(COORD position = COORD{-1, -1});
void hideCursor(bool hide);
void clearScreen();
void print(std::string content, Types::Color code = Types::Color::White, char end = -1);
// selectionList();
};
}
}
// finance.cpp
#include "types.hpp"
#include <iostream>
using namespace Engine::Core;
// Bank
Bank::Bank()
{
this->reserve = 20550;
}
// Accounts
Account::Account()
{
this->balance = 0;
}
int Account::fundAccount(int amount)
{
this->balance += amount;
std::cout << "$" << amount << " credited to " << this->holder->name << "'s account" << std::endl;
return this->balance;
}
int Account::retrieveBalance()
{
return this->balance;
}
int Account::transferFund(Core::Player *reciever, int amount)
{
if (this->balance < amount)
{
std::cout << "Not enough balance in account!" << std::endl;
return this->retrieveBalance();
}
this->balance -= amount;
reciever->account.fundAccount(amount);
return this->retrieveBalance();
}