diff --git a/Projects/Oligopoly/Company.json b/Projects/Oligopoly/Company.json
index 5ab373d6..98df0feb 100644
--- a/Projects/Oligopoly/Company.json
+++ b/Projects/Oligopoly/Company.json
@@ -34,5 +34,19 @@
"SharePrice": 1200,
"NumberOfShares": 0,
"Description": "COBRA (stands for Counter-Offensive Brigades for Rapid Action) are private special forces units equipped with the latest technology. The company fulfills orders all over the world and cooperates with various governments. COBRA Security Consulting is a professional and discreet company that offers security services for high-risk situations and locations. COBRA Security Consulting also trains and equips its operatives with advanced weapons and gadgets to ensure their success."
+ },
+ {
+ "Name": "Rockland Games",
+ "Industry": "Games",
+ "SharePrice": 750,
+ "NumberOfShares": 0,
+ "Description": "Well-known gaming company. Rockland Games are famous for their large and elaborate games across a wide range of genres. The company is also investing in the development of virtual reality and augmented reality to provide its users with a unique gaming experience."
+ },
+ {
+ "Name": "Astro Technologies",
+ "Industry": "Space",
+ "SharePrice": 2500,
+ "NumberOfShares": 0,
+ "Description": "Astro Technologies is a leading space technology and research company. The company invests in the development of satellite systems, space and aerospace technologies. In addition, Astro Technologies is actively collaborating with other space agencies and research institution to foster innovation and promote global cooperation in space exploration."
}
]
\ No newline at end of file
diff --git a/Projects/Oligopoly/Event.json b/Projects/Oligopoly/Event.json
index 867aeb5d..fd9946dc 100644
--- a/Projects/Oligopoly/Event.json
+++ b/Projects/Oligopoly/Event.json
@@ -298,5 +298,125 @@
"Description": "Several COBRA Security Consulting employees have been arrested for engaging in illegal activity, such as smuggling weapons or drugs, while on duty. The company denies any knowledge or involvement in the illegal activity and is cooperating with the authorities to investigate the matter. However, the incident may damage the company\u0027s reputation and credibility, and it may face legal consequences if found guilty of any wrongdoing.",
"CompanyName": "COBRA Security Consulting",
"Effect": -5
+ },
+ {
+ "Title": "Rockland Games announces a highly anticipated new game",
+ "Description": "Rockland Games has revealed the development of a new game that has generated significant excitement among gamers and the industry. The upcoming title promises innovative gameplay mechanics, stunning visuals, and a captivating storyline. The announcement has sparked a surge in pre-orders and positive anticipation, indicating potential success for Rockland Games.",
+ "CompanyName": "Rockland Games",
+ "Effect": 15
+ },
+ {
+ "Title": "Rockland Games expands into mobile gaming market",
+ "Description": "Rockland Games has announced it's expansion into the mobile gaming market. The company plans to release a series of mobile games that will leverage its expertise in creating immersive gaming experiences. This strategic move aims to reach a wider audience and tap into the lucrative mobile gaming industry.",
+ "CompanyName": "Rockland Games",
+ "Effect": 10
+ },
+ {
+ "Title": "Rockland Games unveils a groundbreaking virtual reality game",
+ "Description": "Rockland Games has revealed its latest venture into virtual reality gaming. The company has developed a highly immersive virtual reality game that pushes the boundaries of the medium. Players will be transported to breathtaking virtual worlds, allowing for unprecedented levels of immersion and interactivity. The announcement has generated considerable buzz and anticipation among virtual reality enthusiasts.",
+ "CompanyName": "Rockland Games",
+ "Effect": 5
+ },
+ {
+ "Title": "Rockland Games hosts a major esports tournament",
+ "Description": "Rockland Games is organizing a large-scale esports tournament featuring its flagship competitive titles. The event will attract top professional gamers from around the world, showcasing their skills and competing for substantial cash prizes. The tournament aims to further establish company presence in the esports scene and attract a dedicated community of competitive gamers.",
+ "CompanyName": "Rockland Games",
+ "Effect": 5
+ },
+ {
+ "Title": "Rockland Games' latest game receives critical acclaim and industry awards",
+ "Description": "Rockland Games' recently released game receives glowing reviews from critics and wins prestigious industry awards. The game's innovative gameplay, captivating narrative, and high production values are praised by players and industry professionals alike. The positive reception contributes to increased sales, boosts the company's reputation, and positions Rockland Games as a key player in the gaming industry.",
+ "CompanyName": "Rockland Games",
+ "Effect": 5
+ },
+ {
+ "Title": "Rockland Games announces a significant delay for its highly anticipated game",
+ "Description": "Rockland Games informs the public that the release of their highly anticipated game will be delayed. The delay is attributed to unforeseen technical challenges and the need for additional development time. This announcement disappoints fans and investors, leading to a decrease in pre-orders and a temporary decline in the company's stock value.",
+ "CompanyName": "Rockland Games",
+ "Effect": -15
+ },
+ {
+ "Title": "Rockland Games' highly anticipated game fails to meet expectations",
+ "Description": "Despite significant hype and marketing efforts, Rockland Games' highly anticipated game fails to resonate with players and critics. The game receives poor reviews, citing issues such as technical glitches, lackluster gameplay, or a poorly executed storyline. The disappointment among players and the negative reception impact the game's sales, resulting in financial losses for Rockland Games and a blow to its reputation as a leading game developer.",
+ "CompanyName": "Rockland Games",
+ "Effect": -10
+ },
+ {
+ "Title": "Reports of overworking and employee burnout at Rockland Games",
+ "Description": "Reports surface overworking and employee burnout at Rockland Games. Current and former employees come forward, sharing their experiences of excessive work hours, unrealistic deadlines, and a lack of work-life balance. The news sparks public outcry and raises concerns about the company's treatment of its employees, leading to a negative impact on the company's reputation and employee morale.",
+ "CompanyName": "Rockland Games",
+ "Effect": -5
+ },
+ {
+ "Title": "Rockland Games' anti-cheat system bypassed by hackers",
+ "Description": "Hackers successfully bypass Rockland Games' highly touted anti-cheat system, exposing vulnerabilities in the game's security infrastructure. The hackers exploit these weaknesses to develop and distribute cheat software widely, allowing players to gain unfair advantages in the game. The news spreads quickly, damaging the company's reputation and creating a negative perception among players who question the effectiveness of Rockland Games' security measures. The company is forced to allocate additional resources to fix the security flaws and strengthen their anti-cheat system.",
+ "CompanyName": "Rockland Games",
+ "Effect": -5
+ },
+ {
+ "Title": "Rockland Games announces the closure of one of its beloved games",
+ "Description": "Rockland Games delivers the heartbreaking news that one of its popular games will be shut down. The decision is attributed to declining player numbers, the game's outdated technology, and the company's focus on developing new projects. The announcement triggers a wave of disappointment and sadness among the game's dedicated community, leading to protests and petitions to save the game. Despite the uproar, Rockland Games stands firm on its decision, causing a loss of player trust and potentially impacting the company's overall player base.",
+ "CompanyName": "Rockland Games",
+ "Effect": -5
+ },
+ {
+ "Title": "Astro Technologies successfully collects soil samples from Mars",
+ "Description": "Astro Technologies achieves a historic milestone by successfully collecting soil samples from the surface of Mars. The mission involved the deployment of advanced robotic systems and the utilization of cutting-edge technology to safely gather and preserve the samples. The collected soil samples hold immense scientific value, providing crucial insights into the geological composition, potential signs of life, and the history of Mars. This remarkable achievement garners global attention and solidifies Astro Technologies' position as a pioneering space research company at the forefront of Mars exploration.",
+ "CompanyName": "Astro Technologies",
+ "Effect": 15
+ },
+ {
+ "Title": "Astro Technologies successfully sends a drone to the Moon",
+ "Description": "Astro Technologies makes history by successfully launching a drone mission to the Moon. The drone is equipped with advanced sensors and imaging technology, enabling it to capture high-resolution images and collect valuable data about the lunar surface. The mission aims to explore previously unexplored regions, study lunar geology, and gain a deeper understanding of the Moon's environment. This achievement showcases Astro Technologies' technological prowess and reinforces its position as a leading space exploration company.",
+ "CompanyName": "Astro Technologies",
+ "Effect": 10
+ },
+ {
+ "Title": "Astro Technologies successfully launches advanced satellite system",
+ "Description": "Astro Technologies achieves a major milestone by successfully launching its state-of-the-art satellite system into orbit. The advanced satellite is equipped with cutting-edge technology, enabling improved communication, data collection, and remote sensing capabilities. This accomplishment boosts Astro Technologies' reputation as a leading space technology company and opens up new opportunities for collaboration and business growth.",
+ "CompanyName": "Astro Technologies",
+ "Effect": 5
+ },
+ {
+ "Title": "Astro Technologies captures stunning images of distant galaxies",
+ "Description": "Astro Technologies deploys powerful telescopes and imaging equipment to capture breathtaking images of distant galaxies and celestial objects. The high-resolution pictures reveal intricate details and vibrant colors, captivating both scientists and the general public alike. These images contribute to the advancement of astronomical knowledge, inspiring awe and wonder about the vastness and beauty of the universe. Astro Technologies' space pictures garner widespread appreciation and acclaim, enhancing its reputation as a leader in space technology and research.",
+ "CompanyName": "Astro Technologies",
+ "Effect": 5
+ },
+ {
+ "Title": "Astro Technologies unveils revolutionary new rocket engine",
+ "Description": "Astro Technologies introduces a groundbreaking rocket engine that revolutionizes space travel. The new engine boasts significant improvements in efficiency, power, and safety, enabling more ambitious space missions and reducing the cost of launching payloads into orbit. This technological breakthrough propels Astro Technologies to the forefront of space exploration, attracting the attention of other space agencies and commercial partners. The new rocket engine opens up new possibilities for space exploration and establishes Astro Technologies as a leading innovator in space propulsion systems.",
+ "CompanyName": "Astro Technologies",
+ "Effect": 5
+ },
+ {
+ "Title": "Astro Technologies experiences a rocket failure during launch",
+ "Description": "During a high-profile rocket launch, Astro Technologies encounters a catastrophic failure resulting in the loss of the spacecraft and payload. The incident leads to significant financial losses, delays in planned missions, and a blow to the company's reputation. The investigation into the cause of the failure is launched to prevent similar incidents in the future. Astro Technologies reassesses its engineering processes and implements stricter quality control measures to regain trust and ensure the safety and success of future space missions.",
+ "CompanyName": "Astro Technologies",
+ "Effect": -15
+ },
+ {
+ "Title": "Astro Technologies experiences loss of connection with a critical satellite",
+ "Description": "Astro Technologies encounters a disruption in communication with one of its crucial satellites. The loss of connection hampers the company's ability to retrieve data, control the satellite's functions, and perform planned operations. The incident causes delays in data collection and transmission, affecting scientific research and limiting the satellite's full potential. Astro Technologies swiftly initiates troubleshooting procedures, working diligently to restore the connection and prevent further disruptions in satellite operations.",
+ "CompanyName": "Astro Technologies",
+ "Effect": -10
+ },
+ {
+ "Title": "Astro Technologies faces budget cuts impacting space technology development",
+ "Description": "Astro Technologies experiences budget cuts that significantly affect its research and development efforts in space technology. The reduced funding hampers the company's ability to pursue ambitious projects, slowing down innovation and limiting its competitive edge. Astro Technologies explores alternative funding sources and cost-saving measures to mitigate the impact of the budget cuts.",
+ "CompanyName": "Astro Technologies",
+ "Effect": -5
+ },
+ {
+ "Title": "Astro Technologies' error in satellite launch coordinates leads to misplacement",
+ "Description": "During the launch of a satellite, Astro Technologies encounters an error in the calculated launch coordinates, resulting in the satellite being placed in the wrong orbit or location. This misplacement negatively affects the satellite's intended mission objectives, data collection capabilities, or communication capabilities. Astro Technologies quickly assesses the situation and explores potential solutions, such as orbital adjustments or alternative mission plans, to maximize the satellite's utility despite the initial error. The incident serves as a valuable lesson for future launches, prompting Astro Technologies to enhance its quality control and verification processes.",
+ "CompanyName": "Astro Technologies",
+ "Effect": -5
+ },
+ {
+ "Title": "Astro Technologies faces the dismissal of a key employee",
+ "Description": "Astro Technologies experiences the departure of a key employee who played a crucial role in the company's space technology development and research efforts. The loss of this employee disrupts ongoing projects, hampers knowledge transfer, and creates a void in expertise within the organization. The departure may be due to personal reasons, career opportunities elsewhere, or organizational restructuring. Astro Technologies implements succession planning and talent acquisition strategies to fill the gap left by the key employee and ensure the continuity of its space technology advancements.",
+ "CompanyName": "Astro Technologies",
+ "Effect": -5
}
]
\ No newline at end of file
diff --git a/Projects/Oligopoly/GlobalEvent.json b/Projects/Oligopoly/GlobalEvent.json
new file mode 100644
index 00000000..09cd9f52
--- /dev/null
+++ b/Projects/Oligopoly/GlobalEvent.json
@@ -0,0 +1,32 @@
+[
+ {
+ "Title": "Government Investments",
+ "Description": "The government has announced a massive investment program aimed at stimulating economic growth and supporting key industries. Companies received significant amounts of money for further development. This had a positive impact on share prices and attracted many new investors.",
+ "Effect": 30
+ },
+ {
+ "Title": "Technological Breakthrough",
+ "Description": "A groundbreaking technological innovation has been announced, revolutionizing a particular industry or multiple sectors. This breakthrough has the potential to disrupt traditional business models, improve efficiency, and drive significant growth. Investors are optimistic about the future prospects of companies involved in the new technology, leading to a surge in their stock prices.",
+ "Effect": 30
+ },
+ {
+ "Title": "New Trade Agreements",
+ "Description": "A series of new trade agreements have been successfully negotiated between multiple countries, fostering increased international trade and cooperation. These agreements aim to reduce tariffs, eliminate trade barriers, and promote fair and balanced economic relationships. The market responds positively to the potential for expanded market access and improved trade conditions, leading to an increase in stock prices for companies involved in global trade and benefiting from the new trade agreements.",
+ "Effect": 30
+ },
+ {
+ "Title": "Government Regulation",
+ "Description": "A government has introduced new regulations or policies that impact various industries. These regulations could include stricter environmental standards, increased taxes, or limitations on certain business practices. The implementation of such regulations can lead to increased costs for companies and a decrease in their profitability, causing a decline in stock prices.",
+ "Effect": -30
+ },
+ {
+ "Title": "Major Earthquake",
+ "Description": "A catastrophic earthquake of significant magnitude has struck a region that is home to several major global companies. The earthquake has caused extensive damage to critical infrastructure, including manufacturing facilities, distribution centers, and transportation networks. This disruption severely impacts the operations and supply chains of these companies, leading to a decline in their stock prices. Additionally, the uncertainty surrounding the recovery and reconstruction efforts further contributes to investor concerns and market volatility.",
+ "Effect": -30
+ },
+ {
+ "Title": "Economic Crisis",
+ "Description": "A global economic crisis has emerged, marked by widespread financial instability, high unemployment rates, and decreased consumer confidence. The crisis is driven by a series of factors, including a sharp decline in business activity, reduced investment, and a contraction in international trade. Stock markets experience a significant downturn, leading to a decline in stock prices for companies across various sectors and a period of economic uncertainty and hardship.",
+ "Effect": 30
+ }
+]
\ No newline at end of file
diff --git a/Projects/Oligopoly/Oligopoly.csproj b/Projects/Oligopoly/Oligopoly.csproj
index eeed3eb0..8e7bdcba 100644
--- a/Projects/Oligopoly/Oligopoly.csproj
+++ b/Projects/Oligopoly/Oligopoly.csproj
@@ -8,9 +8,11 @@
+
+
diff --git a/Projects/Oligopoly/Program.cs b/Projects/Oligopoly/Program.cs
index 945dfd50..868d7cb6 100644
--- a/Projects/Oligopoly/Program.cs
+++ b/Projects/Oligopoly/Program.cs
@@ -13,10 +13,14 @@ public class Program
private static bool CloseRequested { get; set; } = false;
private static List Companies { get; set; } = null!;
private static List Events { get; set; } = null!;
+ private static List GlobalEvents { get; set; } = null!;
private static Event CurrentEvent { get; set; } = null!;
- private static decimal Money { get; set; }
- private const decimal LosingNetWorth = 2000.00m;
- private const decimal WinningNetWorth = 50000.00m;
+ private static int PositiveEventChance { get; set; }
+ private static int TurnCounter { get; set; }
+ private static decimal Money = 10000m;
+ private static decimal NetWorth { get; set; }
+ private static decimal LosingNetWorth = 2000.00m;
+ private static decimal WinningNetWorth = 50000.00m;
public static void Main()
{
@@ -67,6 +71,10 @@ private static void LoadEmbeddedResources()
using Stream? stream = assembly.GetManifestResourceStream("Oligopoly.Event.json");
Events = JsonSerializer.Deserialize>(stream!)!;
}
+ {
+ using Stream? stream = assembly.GetManifestResourceStream("Oligopoly.GlobalEvent.json");
+ GlobalEvents = JsonSerializer.Deserialize>(stream!)!;
+ }
}
private static void MainMenuScreen()
@@ -105,16 +113,65 @@ private static void MainMenuScreen()
Console.ReadKey(true);
}
- private static void InitializeGame()
+ private static void GameSetupScreen()
{
- Money = 10000.00m;
+ string prompt = @"
+ ██████╗ █████╗ ███╗ ███╗███████╗ ███████╗███████╗████████╗██╗ ██╗██████╗
+██╔════╝ ██╔══██╗████╗ ████║██╔════╝ ██╔════╝██╔════╝╚══██╔══╝██║ ██║██╔══██╗
+██║ ███╗███████║██╔████╔██║█████╗ ███████╗█████╗ ██║ ██║ ██║██████╔╝
+██║ ██║██╔══██║██║╚██╔╝██║██╔══╝ ╚════██║██╔══╝ ██║ ██║ ██║██╔═══╝
+╚██████╔╝██║ ██║██║ ╚═╝ ██║███████╗ ███████║███████╗ ██║ ╚██████╔╝██║
+ ╚═════╝ ╚═╝ ╚═╝╚═╝ ╚═╝╚══════╝ ╚══════╝╚══════╝ ╚═╝ ╚═════╝ ╚═╝
+ Customize the game to make it interesting for you to play ;)
+";
+ string[] difficultiesOptions = { "Easy", "Normal", "Hard" };
+ string[] gameModesOptions = { "Standard", "Random", "Custom" };
+ string[] difficultiesDescriptions =
+ {
+ "60% chance that the next market event will be positive",
+ "50% chance that the next market event will be positive/negative",
+ "60% change that the next market event will be negative"
+ };
+ string[] gameModesDescriptions =
+ {
+ "Just standard mode, nothing out of the ordinary",
+ "Your money and company shares prices will be randomly generated",
+ "You can set the starting amount of your money"
+ };
+
+ TurnCounter = 1;
LoadEmbeddedResources();
+ int selectedMode = HandleMenuWithOptions(prompt, gameModesOptions, gameModesDescriptions);
+ int selectedDifficulty = HandleMenuWithOptions(prompt, difficultiesOptions, difficultiesDescriptions);
+
+ switch (selectedDifficulty)
+ {
+ case 0: PositiveEventChance = 60; break;
+ case 1: PositiveEventChance = 50; break;
+ case 2: PositiveEventChance = 40; break;
+ }
+
+ switch (selectedMode)
+ {
+ case 1:
+ foreach (Company company in Companies)
+ {
+ company.SharePrice = Random.Shared.Next(100, 5001);
+ }
+ Money = Random.Shared.Next(1000, 30001);
+ break;
+ case 2:
+ Money = MoneySetupScreen();
+ break;
+ }
}
private static void GameLoop()
{
while (!CloseRequested)
{
+ CalculateNetWorth();
+
int selectedOption = -1;
while (!CloseRequested && selectedOption is not 0)
{
@@ -136,29 +193,58 @@ private static void GameLoop()
}
}
+ UpdateSharePrices();
EventScreen();
- switch (CalculateNetWorth())
+ if (NetWorth > WinningNetWorth)
+ {
+ PlayerWinsScreen();
+ return;
+ }
+ else if (NetWorth < LosingNetWorth)
{
- case >= WinningNetWorth: PlayerWinsScreen(); return;
- case <= LosingNetWorth: PlayerLosesScreen(); return;
+ PlayerLosesScreen();
+ return;
}
+
+ TurnCounter++;
}
}
private static void EventScreen()
{
- CurrentEvent = Events[Random.Shared.Next(0, Events.Count)];
+ StringBuilder prompt = RenderCompanyStocksTable();
+ prompt.AppendLine();
- foreach (Company currentCompany in Companies)
+ bool isPositive = Random.Shared.Next(0, 101) <= PositiveEventChance;
+
+ if (TurnCounter % 50 == 0)
+ {
+ if (isPositive)
+ {
+ List positiveGlobalEvents = GlobalEvents.Where(e => e.Effect > 0).ToList();
+ CurrentEvent = positiveGlobalEvents[Random.Shared.Next(0, positiveGlobalEvents.Count)];
+ }
+ else
+ {
+ List negativeGlobalEvents = GlobalEvents.Where(e => e.Effect < 0).ToList();
+ CurrentEvent = negativeGlobalEvents[Random.Shared.Next(0, negativeGlobalEvents.Count)];
+ }
+ }
+ else
{
- if (currentCompany.Name == CurrentEvent.CompanyName)
+ if (isPositive)
+ {
+ List positiveEvents = Events.Where(e => e.Effect > 0).ToList();
+ CurrentEvent = positiveEvents[Random.Shared.Next(0, positiveEvents.Count)];
+ }
+ else
{
- currentCompany.SharePrice += currentCompany.SharePrice * CurrentEvent.Effect / 100;
+ List negativeEvents = Events.Where(e => e.Effect < 0).ToList();
+ CurrentEvent = negativeEvents[Random.Shared.Next(0, negativeEvents.Count)];
}
}
- StringBuilder prompt = RenderCompanyStocksTable();
prompt.AppendLine();
prompt.AppendLine($"{CurrentEvent.Title}");
prompt.AppendLine();
@@ -194,12 +280,12 @@ private static void BuyOrSellStockScreen(bool isBuying)
if (i == index)
{
(Console.BackgroundColor, Console.ForegroundColor) = (Console.ForegroundColor, Console.BackgroundColor);
- Console.WriteLine($" < {numberOfShares[i]}{(!isBuying ? $"/{Companies[index].NumberOfShares}" : "")} > {Companies[i].Name}");
+ Console.WriteLine($" < {numberOfShares[i]}{(!isBuying ? $"/{Companies[i].NumberOfShares}" : "")} > {Companies[i].Name}");
Console.ResetColor();
}
else
{
- Console.WriteLine($" {numberOfShares[i]}{(!isBuying ? $"/{Companies[index].NumberOfShares}" : "")} {Companies[i].Name}");
+ Console.WriteLine($" {numberOfShares[i]}{(!isBuying ? $"/{Companies[i].NumberOfShares}" : "")} {Companies[i].Name}");
}
}
Console.WriteLine();
@@ -233,7 +319,7 @@ private static void BuyOrSellStockScreen(bool isBuying)
numberOfShares[index]--;
}
break;
-
+
}
}
@@ -268,6 +354,61 @@ private static void BuyOrSellStockScreen(bool isBuying)
CloseRequested = CloseRequested || Console.ReadKey(true).Key is ConsoleKey.Escape;
}
+ private static int MoneySetupScreen()
+ {
+ bool isEnd = false;
+ int index = 0, customMoney = 1000;
+ string[] options = { "(+) Increase", "(-) Decrease", "Done"};
+ ConsoleKey key = default;
+ while (!CloseRequested && !isEnd)
+ {
+ Console.Clear();
+ Console.WriteLine($"Your starting amount of money will be set to {customMoney:C}");
+ Console.WriteLine("Use up and down arrow keys and enter to select an option:\n");
+ for (int i = 0; i < options.Length; i++)
+ {
+ string currentOption = options[i];
+ if (i == index)
+ {
+ (Console.BackgroundColor, Console.ForegroundColor) = (Console.ForegroundColor, Console.BackgroundColor);
+ Console.WriteLine($"[*] {currentOption}");
+ Console.ResetColor();
+ }
+ else
+ {
+ Console.WriteLine($"[ ] {currentOption}");
+ }
+ }
+
+ Console.CursorVisible = false;
+ key = Console.ReadKey().Key;
+ switch (key)
+ {
+ case ConsoleKey.UpArrow: index = index is 0 ? options.Length - 1 : index - 1; break;
+ case ConsoleKey.DownArrow: index = index == options.Length - 1 ? 0 : index + 1; break;
+ case ConsoleKey.Enter:
+ if (index == 0)
+ {
+ customMoney += 100;
+ }
+ else if (index == 1)
+ {
+ if (customMoney - 100 >= 1000)
+ {
+ customMoney -= 100;
+ }
+ }
+ else
+ {
+ isEnd = true;
+ }
+ break;
+ case ConsoleKey.Escape: CloseRequested = true; break;
+ }
+ }
+ return customMoney;
+ }
+
private static void CompanyDetailsScreen()
{
Console.Clear();
@@ -284,59 +425,71 @@ private static void CompanyDetailsScreen()
private static void IntroductionScreen()
{
Console.Clear();
- Console.WriteLine();
- Console.WriteLine(" ┌────────────────────────────────────────────────────────────────────────────────┐");
- Console.WriteLine(" │ Dear CEO, │");
- Console.WriteLine(" │ │");
- Console.WriteLine(" │ Welcome to Oligopoly! │");
- Console.WriteLine(" │ │");
- Console.WriteLine(" │ On behalf of the board of directors of Oligopoly Investments, we would like to │");
- Console.WriteLine(" │ congratulate you on becoming our new CEO. We are confident that you will lead │");
- Console.WriteLine(" │ our company to new heights of success and innovation. As CEO, you now have │");
- Console.WriteLine(" │ access to our exclusive internal software called Oligopoly, where you can |");
- Console.WriteLine(" │ track the latest news from leading companies and buy and sell their shares. │");
- Console.WriteLine(" │ This software will give you an edge over the competition and help you make │");
- Console.WriteLine(" │ important decisions for our company. To access the program, simply click the │");
- Console.WriteLine(" │ button at the bottom of this email. We look forward to working with you and │");
- Console.WriteLine(" │ supporting you in your new role. │");
- Console.WriteLine(" │ │");
- Console.WriteLine(" │ Sincerely, │");
- Console.WriteLine(" │ The board of directors of Oligopoly Investments │");
- Console.WriteLine(" └────────────────────────────────────────────────────────────────────────────────┘");
- Console.WriteLine();
+ Console.WriteLine(@"
+ ██╗ ██╗███████╗██╗ ██████╗ ██████╗ ███╗ ███╗███████╗
+ ██║ ██║██╔════╝██║ ██╔════╝██╔═══██╗████╗ ████║██╔════╝
+ ██║ █╗ ██║█████╗ ██║ ██║ ██║ ██║██╔████╔██║█████╗
+ ██║███╗██║██╔══╝ ██║ ██║ ██║ ██║██║╚██╔╝██║██╔══╝
+ ╚███╔███╔╝███████╗███████╗╚██████╗╚██████╔╝██║ ╚═╝ ██║███████╗
+ ╚══╝╚══╝ ╚══════╝╚══════╝ ╚═════╝ ╚═════╝ ╚═╝ ╚═╝╚══════╝
+╔════════════════════════════════════════════════════════════════════════════════╗
+║ Dear new CEO, ║
+║ ║
+║ Welcome to Oligopoly! ║
+║ ║
+║ On behalf of the board of directors of Oligopoly Investments, we would like to ║
+║ congratulate you on becoming our new CEO. We are confident that you will lead ║
+║ our company to new heights of success and innovation. As CEO, you now have ║
+║ access to our exclusive internal software called Oligopoly, where you can ║
+║ track the latest news from leading companies and buy and sell their shares. ║
+║ This software will give you an edge over the competition and help you make ║
+║ important decisions for our company. To access the program, simply click the ║
+║ button at the bottom of this email. We look forward to working with you and ║
+║ supporting you in your new role. ║
+║ ║
+║ Sincerely, ║
+║ The board of directors of Oligopoly Investments ║
+╚════════════════════════════════════════════════════════════════════════════════╝
+");
Console.Write("Press any key to continue...");
Console.CursorVisible = false;
CloseRequested = CloseRequested || Console.ReadKey(true).Key is ConsoleKey.Escape;
- InitializeGame();
+ GameSetupScreen();
GameLoop();
}
private static void PlayerWinsScreen()
{
Console.Clear();
- Console.WriteLine();
- Console.WriteLine(" ┌────────────────────────────────────────────────────────────────────────────────┐");
- Console.WriteLine(" │ Dear CEO, │");
- Console.WriteLine(" │ │");
- Console.WriteLine(" │ On behalf of the board of directors of Oligopoly Investments, we would like to │");
- Console.WriteLine(" │ express our gratitude and understanding for your decision to leave your post. │");
- Console.WriteLine(" │ You have been a remarkable leader and a visionary strategist, who played the │");
- Console.WriteLine(" │ stock market skillfully and increased our budget by five times. We are proud │");
- Console.WriteLine(" │ of your achievements and we wish you all the best in your future endeavors. As │");
- Console.WriteLine(" │ a token of our appreciation, we are pleased to inform you that the company │");
- Console.WriteLine(" │ will pay you a bonus of $1 million. You deserve this reward for your hard work │");
- Console.WriteLine(" │ and dedication. We hope you will enjoy it and remember us fondly. Thank you │");
- Console.WriteLine(" │ for your service and your contribution to Oligopoly Investments. │");
- Console.WriteLine(" │ You will be missed. │");
- Console.WriteLine(" │ │");
- Console.WriteLine(" │ Sincerely, │");
- Console.WriteLine(" │ The board of directors of Oligopoly Investments │");
- Console.WriteLine(" └────────────────────────────────────────────────────────────────────────────────┘");
- Console.WriteLine();
- Console.WriteLine($"Your net worth is over {WinningNetWorth:C}.");
- Console.WriteLine();
- Console.WriteLine("You win! Congratulations!");
- Console.WriteLine();
+ Console.WriteLine(@$"
+ ██╗ ██╗ ██████╗ ██╗ ██╗ ██╗ ██╗██╗███╗ ██╗
+ ╚██╗ ██╔╝██╔═══██╗██║ ██║ ██║ ██║██║████╗ ██║
+ ╚████╔╝ ██║ ██║██║ ██║ ██║ █╗ ██║██║██╔██╗ ██║
+ ╚██╔╝ ██║ ██║██║ ██║ ██║███╗██║██║██║╚██╗██║
+ ██║ ╚██████╔╝╚██████╔╝ ╚███╔███╔╝██║██║ ╚████║
+ ╚═╝ ╚═════╝ ╚═════╝ ╚══╝╚══╝ ╚═╝╚═╝ ╚═══╝
+╔════════════════════════════════════════════════════════════════════════════════╗
+║ Dear CEO, ║
+║ ║
+║ On behalf of the board of directors of Oligopoly Investments, we would like to ║
+║ express our gratitude and understanding for your decision to leave your post. ║
+║ You have been a remarkable leader and a visionary strategist, who played the ║
+║ stock market skillfully and increased our budget by five times. We are proud ║
+║ of your achievements and we wish you all the best in your future endeavors. As ║
+║ a token of our appreciation, we are pleased to inform you that the company ║
+║ will pay you a bonus of $1 million. You deserve this reward for your hard work ║
+║ and dedication. We hope you will enjoy it and remember us fondly. Thank you ║
+║ for your service and your contribution to Oligopoly Investments. ║
+║ You will be missed. ║
+║ ║
+║ Sincerely, ║
+║ The board of directors of Oligopoly Investments ║
+╚════════════════════════════════════════════════════════════════════════════════╝
+
+Your Net Worth is over {WinningNetWorth}$
+You have played {TurnCounter} turns
+Congratulations!
+");
Console.Write("Press any key (except ENTER) to continue...");
ConsoleKey key = ConsoleKey.Enter;
while (!CloseRequested && key is ConsoleKey.Enter)
@@ -350,25 +503,31 @@ private static void PlayerWinsScreen()
private static void PlayerLosesScreen()
{
Console.Clear();
- Console.WriteLine();
- Console.WriteLine(" ┌────────────────────────────────────────────────────────────────────────────────┐");
- Console.WriteLine(" │ Dear former CEO, │");
- Console.WriteLine(" │ │");
- Console.WriteLine(" │ We regret to inform you that you are being removed from the position of CEO │");
- Console.WriteLine(" │ and fired from the company, effective immediately. The board of directors of │");
- Console.WriteLine(" │ Oligopoly Investments has decided to take this action because you have spent │");
- Console.WriteLine(" │ the budget allocated to you, and your investment turned out to be unprofitable │");
- Console.WriteLine(" │ for the company. We appreciate your service and wish you all the best in your │");
- Console.WriteLine(" │ future endeavors. │");
- Console.WriteLine(" │ │");
- Console.WriteLine(" │ Sincerely, │");
- Console.WriteLine(" │ The board of directors of Oligopoly Investments │");
- Console.WriteLine(" └────────────────────────────────────────────────────────────────────────────────┘");
- Console.WriteLine();
- Console.WriteLine($"Your net worth dropped below {LosingNetWorth:C}.");
- Console.WriteLine();
- Console.WriteLine("You Lose! Better luck next time...");
- Console.WriteLine();
+ Console.WriteLine($@"
+ ██╗ ██╗ ██████╗ ██╗ ██╗ ██╗ ██████╗ ███████╗███████╗
+ ╚██╗ ██╔╝██╔═══██╗██║ ██║ ██║ ██╔═══██╗██╔════╝██╔════╝
+ ╚████╔╝ ██║ ██║██║ ██║ ██║ ██║ ██║███████╗█████╗
+ ╚██╔╝ ██║ ██║██║ ██║ ██║ ██║ ██║╚════██║██╔══╝
+ ██║ ╚██████╔╝╚██████╔╝ ███████╗╚██████╔╝███████║███████╗
+ ╚═╝ ╚═════╝ ╚═════╝ ╚══════╝ ╚═════╝ ╚══════╝╚══════╝
+╔════════════════════════════════════════════════════════════════════════════════╗
+║ Dear former CEO, ║
+║ ║
+║ We regret to inform you that you are being removed from the position of CEO ║
+║ and fired from the company, effective immediately. The board of directors of ║
+║ Oligopoly Investments has decided to take this action because you have spent ║
+║ the budget allocated to you, and your investment turned out to be unprofitable ║
+║ for the company. We appreciate your service and wish you all the best in your ║
+║ future endeavors. ║
+║ ║
+║ Sincerely, ║
+║ The board of directors of Oligopoly Investments ║
+╚════════════════════════════════════════════════════════════════════════════════╝
+
+Your Net Worth dropped below {LosingNetWorth}$
+You have played {TurnCounter} turns
+Better luck next time...
+");
Console.Write("Press any key (except ENTER) to continue...");
ConsoleKey key = ConsoleKey.Enter;
while (!CloseRequested && key is ConsoleKey.Enter)
@@ -382,15 +541,20 @@ private static void PlayerLosesScreen()
private static void AboutInfoScreen()
{
Console.Clear();
- Console.WriteLine();
- Console.WriteLine(" |");
- Console.WriteLine(" | THANKS!");
- Console.WriteLine(" |");
- Console.WriteLine(" | No really, thank you for taking time to play this simple console game. It means a lot.");
- Console.WriteLine(" |");
- Console.WriteLine(" | This game was created by Semion Medvedev (Fuinny)");
- Console.WriteLine(" |");
- Console.WriteLine();
+ Console.WriteLine($@"
+ ████████╗██╗ ██╗ █████╗ ███╗ ██╗██╗ ██╗███████╗██╗
+ ╚══██╔══╝██║ ██║██╔══██╗████╗ ██║██║ ██╔╝██╔════╝██║
+ ██║ ███████║███████║██╔██╗ ██║█████╔╝ ███████╗██║
+ ██║ ██╔══██║██╔══██║██║╚██╗██║██╔═██╗ ╚════██║╚═╝
+ ██║ ██║ ██║██║ ██║██║ ╚████║██║ ██╗███████║██╗
+ ╚═╝ ╚═╝ ╚═╝╚═╝ ╚═╝╚═╝ ╚═══╝╚═╝ ╚═╝╚══════╝╚═╝
+╔══════════════════════════════════════════════════════════════════════════════════╗
+║No really, thank you for taking time to play this simple CLI game. It means a lot.║
+║If you find any bug or have an idea how to improve the game, please let me know :D║
+║ ║
+║This game was created by Semion Medvedev (Fuinny) ║
+╚══════════════════════════════════════════════════════════════════════════════════╝
+");
Console.WriteLine("Press any key to continue...");
Console.CursorVisible = false;
CloseRequested = CloseRequested || Console.ReadKey(true).Key is ConsoleKey.Escape;
@@ -402,19 +566,19 @@ private static StringBuilder RenderCompanyStocksTable()
const int c0 = 30, c1 = 10, c2 = 19, c3 = 17;
StringBuilder gameView = new();
- gameView.AppendLine($"╔═{new('═', c0)}═╤═{new('═', c1)}═╤═{new('═', c2)}═╤═{new('═', c3)}═╗");
- gameView.AppendLine($"║ {"Company",-c0} │ {"Industry",c1} │ {"Share Price",c2} │ {"You Have",c3} ║");
- gameView.AppendLine($"╟─{new('─', c0)}─┼─{new('─', c1)}─┼─{new('─', c2)}─┼─{new('─', c3)}─╢");
+ gameView.AppendLine($"╔═{new('═', c0)}═╦═{new('═', c1)}═╦═{new('═', c2)}═╦═{new('═', c3)}═╗");
+ gameView.AppendLine($"║ {"Company",-c0} ║ {"Industry",c1} ║ {"Share Price",c2} ║ {"You Have",c3} ║");
+ gameView.AppendLine($"╠═{new('═', c0)}═╬═{new('═', c1)}═╬═{new('═', c2)}═╬═{new('═', c3)}═╣");
foreach (Company company in Companies)
{
- gameView.AppendLine($"║ {company.Name,-c0} │ {company.Industry,c1} │ {company.SharePrice,c2:C} │ {company.NumberOfShares,c3} ║");
+ gameView.AppendLine($"║ {company.Name,-c0} ║ {company.Industry,c1} ║ {company.SharePrice,c2:C} ║ {company.NumberOfShares,c3} ║");
}
- gameView.AppendLine($"╚═{new('═', c0)}═╧═{new('═', c1)}═╧═{new('═', c2)}═╧═{new('═', c3)}═╝");
- gameView.AppendLine($"Your money: {Money:C} Your Net Worth: {CalculateNetWorth():C}");
+ gameView.AppendLine($"╚═{new('═', c0)}═╩═{new('═', c1)}═╩═{new('═', c2)}═╩═{new('═', c3)}═╝");
+ gameView.AppendLine($"Your money: {Money:C} Your Net Worth: {NetWorth:C} Current Turn: {TurnCounter}");
return gameView;
}
- private static int HandleMenuWithOptions(string prompt, string[] options)
+ private static int HandleMenuWithOptions(string prompt, string[] options, string[] descriptions = null!)
{
int index = 0;
ConsoleKey key = default;
@@ -436,6 +600,11 @@ private static int HandleMenuWithOptions(string prompt, string[] options)
Console.WriteLine($"[ ] {currentOption}");
}
}
+ if (descriptions != null)
+ {
+ Console.WriteLine("\nDescription:");
+ Console.WriteLine(descriptions[index]);
+ }
Console.CursorVisible = false;
key = Console.ReadKey().Key;
switch (key)
@@ -448,13 +617,31 @@ private static int HandleMenuWithOptions(string prompt, string[] options)
return index;
}
- private static decimal CalculateNetWorth()
+ private static void CalculateNetWorth()
{
- decimal netWorth = Money;
+ NetWorth = Money;
foreach (Company company in Companies)
{
- netWorth += company.SharePrice * company.NumberOfShares;
+ NetWorth += company.SharePrice * company.NumberOfShares;
+ }
+ }
+
+ private static void UpdateSharePrices()
+ {
+ for (int i = 0; i < Companies.Count; i++)
+ {
+ Random random = new Random();
+ int effect = random.Next(0, 2);
+
+ switch (effect)
+ {
+ case 0:
+ Companies[i].SharePrice += Companies[i].SharePrice * Random.Shared.Next(1, 4) / 100;
+ break;
+ case 1:
+ Companies[i].SharePrice += Companies[i].SharePrice * Random.Shared.Next(-3, 0) / 100;
+ break;
+ }
}
- return netWorth;
}
}
\ No newline at end of file
diff --git a/Projects/Oligopoly/README.md b/Projects/Oligopoly/README.md
index 2af0e12a..f0d011b5 100644
--- a/Projects/Oligopoly/README.md
+++ b/Projects/Oligopoly/README.md
@@ -24,16 +24,18 @@
Oligopoly is a stock market betting game. Buy stocks in a company and then try to sell them at a higher price to increase your net worth.
```
-╔════════════════════════════════╤════════════╤═════════════════════╤═══════════════════╗
-║ Company │ Industry │ Share Price │ You Have ║
-╟────────────────────────────────┼────────────┼─────────────────────┼───────────────────╢
-║ Bingoo │ Web │ $1,275.75 │ 1 ║
-║ Quantum Software │ Software │ $2,310.00 │ 0 ║
-║ Edison Incorporated │ Energy │ $997.50 │ 0 ║
-║ Netfilm │ Movies │ $882.00 │ 1 ║
-║ COBRA Security Consulting │ Army │ $1,311.00 │ 1 ║
-╚════════════════════════════════╧════════════╧═════════════════════╧═══════════════════╝
-Your money: $6,500.00 Your Net Worth: $9,968.75
+╔════════════════════════════════╦════════════╦═════════════════════╦═══════════════════╗
+║ Company ║ Industry ║ Share Price ║ You Have ║
+╠════════════════════════════════╬════════════╬═════════════════════╬═══════════════════╣
+║ Bingoo ║ Web ║ $1,423.04 ║ 1 ║
+║ Quantum Software ║ Software ║ $2,180.49 ║ 0 ║
+║ Edison Incorporated ║ Energy ║ $1,007.88 ║ 0 ║
+║ Netfilm ║ Movies ║ $872.45 ║ 1 ║
+║ COBRA Security Consulting ║ Army ║ $1,221.27 ║ 1 ║
+║ Rockland Games ║ Games ║ $586.12 ║ 0 ║
+║ Astro Technologies ║ Space ║ $2,363.37 ║ 0 ║
+╚════════════════════════════════╩════════════╩═════════════════════╩═══════════════════╝
+Your money: $6,500.00 Your Net Worth: $10,016.77 Current Turn: 10
Use up and down arrow keys and enter to select an option:
[*] Wait For Market Change
diff --git a/Projects/Website/Games/Oligopoly/Oligopoly.cs b/Projects/Website/Games/Oligopoly/Oligopoly.cs
index 063315ff..93f80f90 100644
--- a/Projects/Website/Games/Oligopoly/Oligopoly.cs
+++ b/Projects/Website/Games/Oligopoly/Oligopoly.cs
@@ -17,11 +17,16 @@ public async Task Run()
#pragma warning disable IDE0059 // Unnecessary assignment of a value
List Companies = null!;
List Events = null!;
+ List GlobalEvents = null!;
Event CurrentEvent = null!;
- decimal Money = 10000.00m;
+ int TurnCounter = 0;
+ string Difficulty = null!;
+ string GameMode = null!;
+ decimal Money = 0m;
+ decimal NetWorth = 0m;
#pragma warning restore IDE0059 // Unnecessary assignment of a value
- const decimal LosingNetWorth = 2000.00m;
- const decimal WinningNetWorth = 50000.00m;
+ decimal LosingNetWorth = 0m;
+ decimal WinningNetWorth = 0m;
try
{
@@ -37,6 +42,7 @@ void LoadEmbeddedResources()
{
Companies = JsonSerializer.Deserialize>(Resources.Company_json!)!;
Events = JsonSerializer.Deserialize>(Resources.Event_json!)!;
+ GlobalEvents = JsonSerializer.Deserialize>(Resources.GlobalEvent_json!)!;
}
async Task MainMenuScreen()
@@ -75,20 +81,115 @@ async Task MainMenuScreen()
await Console.ReadKey(true);
}
+ async Task DisplayGameModeScreen()
+ {
+ string prompt = @"
+ ██████╗ █████╗ ███╗ ███╗███████╗ ███╗ ███╗ ██████╗ ██████╗ ███████╗
+██╔════╝ ██╔══██╗████╗ ████║██╔════╝ ████╗ ████║██╔═══██╗██╔══██╗██╔════╝
+██║ ███╗███████║██╔████╔██║█████╗ ██╔████╔██║██║ ██║██║ ██║█████╗
+██║ ██║██╔══██║██║╚██╔╝██║██╔══╝ ██║╚██╔╝██║██║ ██║██║ ██║██╔══╝
+╚██████╔╝██║ ██║██║ ╚═╝ ██║███████╗ ██║ ╚═╝ ██║╚██████╔╝██████╔╝███████╗
+ ╚═════╝ ╚═╝ ╚═╝╚═╝ ╚═╝╚══════╝ ╚═╝ ╚═╝ ╚═════╝ ╚═════╝ ╚══════╝
+ Use up and down arrow keys to select a game mode
+";
+ string[] options = { "Default", "Random" };
+ string[] descriptions = {
+ "This is the default game mode. Choose the difficulty, buy shares and try to sell them at a higher price to increase your net worth.",
+ "Want to go full random? In this mode, your money and company shares are randomly generated."
+ };
+ int selectedMode = await HandleMenuWithOptions(prompt, options, descriptions);
+ switch (selectedMode)
+ {
+ case 0:
+ GameMode = "default";
+ break;
+ case 1:
+ GameMode = "random";
+ break;
+ }
+ }
+
+ async Task DisplayDifficultiesScreen()
+ {
+ string prompt = @"
+██████╗ ██╗███████╗███████╗██╗ ██████╗██╗ ██╗██╗ ████████╗██╗ ██╗
+██╔══██╗██║██╔════╝██╔════╝██║██╔════╝██║ ██║██║ ╚══██╔══╝╚██╗ ██╔╝
+██║ ██║██║█████╗ █████╗ ██║██║ ██║ ██║██║ ██║ ╚████╔╝
+██║ ██║██║██╔══╝ ██╔══╝ ██║██║ ██║ ██║██║ ██║ ╚██╔╝
+██████╔╝██║██║ ██║ ██║╚██████╗╚██████╔╝███████╗██║ ██║
+╚═════╝ ╚═╝╚═╝ ╚═╝ ╚═╝ ╚═════╝ ╚═════╝ ╚══════╝╚═╝ ╚═╝
+ Use up and down arrow keys to select a difficulty
+";
+ string[] options = { "Easy", "Normal", "Hard" };
+ string[] descriptions = {
+ "You will have 20000$\nYou will lose if your net worth drop below 1000$\nYou will win if your net worth will be over 30000$",
+ "You will have 10000$\nYou will lose if your net worth drop below 2000$\nYou will win if your net worth will be over 50000$",
+ "You will have 5000$\nYou will lose if your net worth drop below 3000$\nYou will win if your net worth will be over 100000$"
+ };
+ int selectedDifficulty = await HandleMenuWithOptions(prompt, options, descriptions);
+ switch (selectedDifficulty)
+ {
+ case 0:
+ Difficulty = "easy";
+ break;
+ case 1:
+ Difficulty = "normal";
+ break;
+ case 2:
+ Difficulty = "hard";
+ break;
+ }
+ }
+
async Task InitializeGame()
{
await Console.Clear();
await Console.Write("loading...");
await Console.Refresh();
- Money = 10000.00m;
- LoadEmbeddedResources();
+ switch (GameMode)
+ {
+ case "default":
+ LoadEmbeddedResources();
+ await DisplayDifficultiesScreen();
+ switch (Difficulty)
+ {
+ case "easy":
+ Money = 20000.00M;
+ LosingNetWorth = 1000.00M;
+ WinningNetWorth = 30000.00M;
+ break;
+ case "normal":
+ Money = 10000.00M;
+ LosingNetWorth = 2000.00M;
+ WinningNetWorth = 50000.00M;
+ break;
+ case "hard":
+ Money = 5000.00M;
+ LosingNetWorth = 3000.00M;
+ WinningNetWorth = 100000.00M;
+ break;
+ }
+ break;
+ case "random":
+ LoadEmbeddedResources();
+ foreach (Company company in Companies)
+ {
+ company.SharePrice = Random.Shared.Next(100, 5001);
+ }
+ Money = Random.Shared.Next(1000, 30001);
+ LosingNetWorth = 2000.00M;
+ WinningNetWorth = 50000.00M;
+ break;
+ }
}
async Task GameLoop()
{
while (!CloseRequested)
{
+ CalculateNetWorth();
+
int selectedOption = -1;
while (!CloseRequested && selectedOption is not 0)
{
@@ -110,31 +211,55 @@ async Task GameLoop()
}
}
+ UpdateSharePrices();
await EventScreen();
- switch (CalculateNetWorth())
+ if (NetWorth > WinningNetWorth)
{
- case >= WinningNetWorth: await PlayerWinsScreen(); return;
- case <= LosingNetWorth: await PlayerLosesScreen(); return;
+ await PlayerWinsScreen();
+ return;
}
+ else if (NetWorth < LosingNetWorth)
+ {
+ await PlayerLosesScreen();
+ return;
+ }
+
+ TurnCounter++;
}
}
async Task EventScreen()
{
- CurrentEvent = Events[Random.Shared.Next(0, Events.Count)];
+ StringBuilder prompt = RenderCompanyStocksTable();
+ prompt.AppendLine();
- foreach (Company currentCompany in Companies)
+ if (TurnCounter % 50 == 0)
{
- if (currentCompany.Name == CurrentEvent.CompanyName)
+ CurrentEvent = GlobalEvents[Random.Shared.Next(0, GlobalEvents.Count)];
+
+ foreach (Company currentCompany in Companies)
{
currentCompany.SharePrice += currentCompany.SharePrice * CurrentEvent.Effect / 100;
}
+
+ prompt.AppendLine($"{CurrentEvent.Title.ToUpper()}");
+ }
+ else
+ {
+ CurrentEvent = Events[Random.Shared.Next(0, Events.Count)];
+
+ foreach (Company currentCompany in Companies)
+ {
+ if (currentCompany.Name == CurrentEvent.CompanyName)
+ {
+ currentCompany.SharePrice += currentCompany.SharePrice * CurrentEvent.Effect / 100;
+ }
+ }
+
+ prompt.AppendLine($"{CurrentEvent.Title}");
}
- StringBuilder prompt = RenderCompanyStocksTable();
- prompt.AppendLine();
- prompt.AppendLine($"{CurrentEvent.Title}");
prompt.AppendLine();
prompt.AppendLine($"{CurrentEvent.Description}");
prompt.AppendLine();
@@ -168,12 +293,12 @@ async Task BuyOrSellStockScreen(bool isBuying)
if (i == index)
{
(Console.BackgroundColor, Console.ForegroundColor) = (Console.ForegroundColor, Console.BackgroundColor);
- await Console.WriteLine($" < {numberOfShares[i]}{(!isBuying ? $"/{Companies[index].NumberOfShares}" : "")} > {Companies[i].Name}");
+ await Console.WriteLine($" < {numberOfShares[i]}{(!isBuying ? $"/{Companies[i].NumberOfShares}" : "")} > {Companies[i].Name}");
Console.ResetColor();
}
else
{
- await Console.WriteLine($" {numberOfShares[i]}{(!isBuying ? $"/{Companies[index].NumberOfShares}" : "")} {Companies[i].Name}");
+ await Console.WriteLine($" {numberOfShares[i]}{(!isBuying ? $"/{Companies[i].NumberOfShares}" : "")} {Companies[i].Name}");
}
}
await Console.WriteLine();
@@ -258,59 +383,88 @@ async Task CompanyDetailsScreen()
async Task IntroductionScreen()
{
await Console.Clear();
- await Console.WriteLine();
- await Console.WriteLine(" ┌────────────────────────────────────────────────────────────────────────────────┐");
- await Console.WriteLine(" │ Dear CEO, │");
- await Console.WriteLine(" │ │");
- await Console.WriteLine(" │ Welcome to Oligopoly! │");
- await Console.WriteLine(" │ │");
- await Console.WriteLine(" │ On behalf of the board of directors of Oligopoly Investments, we would like to │");
- await Console.WriteLine(" │ congratulate you on becoming our new CEO. We are confident that you will lead │");
- await Console.WriteLine(" │ our company to new heights of success and innovation. As CEO, you now have │");
- await Console.WriteLine(" │ access to our exclusive internal software called Oligopoly, where you can |");
- await Console.WriteLine(" │ track the latest news from leading companies and buy and sell their shares. │");
- await Console.WriteLine(" │ This software will give you an edge over the competition and help you make │");
- await Console.WriteLine(" │ important decisions for our company. To access the program, simply click the │");
- await Console.WriteLine(" │ button at the bottom of this email. We look forward to working with you and │");
- await Console.WriteLine(" │ supporting you in your new role. │");
- await Console.WriteLine(" │ │");
- await Console.WriteLine(" │ Sincerely, │");
- await Console.WriteLine(" │ The board of directors of Oligopoly Investments │");
- await Console.WriteLine(" └────────────────────────────────────────────────────────────────────────────────┘");
- await Console.WriteLine();
+ await Console.WriteLine(@"
+ ██╗ ██╗███████╗██╗ ██████╗ ██████╗ ███╗ ███╗███████╗
+ ██║ ██║██╔════╝██║ ██╔════╝██╔═══██╗████╗ ████║██╔════╝
+ ██║ █╗ ██║█████╗ ██║ ██║ ██║ ██║██╔████╔██║█████╗
+ ██║███╗██║██╔══╝ ██║ ██║ ██║ ██║██║╚██╔╝██║██╔══╝
+ ╚███╔███╔╝███████╗███████╗╚██████╗╚██████╔╝██║ ╚═╝ ██║███████╗
+ ╚══╝╚══╝ ╚══════╝╚══════╝ ╚═════╝ ╚═════╝ ╚═╝ ╚═╝╚══════╝
+╔════════════════════════════════════════════════════════════════════════════════╗
+║ Dear new CEO, ║
+║ ║
+║ Welcome to Oligopoly! ║
+║ ║
+║ On behalf of the board of directors of Oligopoly Investments, we would like to ║
+║ congratulate you on becoming our new CEO. We are confident that you will lead ║
+║ our company to new heights of success and innovation. As CEO, you now have ║
+║ access to our exclusive internal software called Oligopoly, where you can ║
+║ track the latest news from leading companies and buy and sell their shares. ║
+║ This software will give you an edge over the competition and help you make ║
+║ important decisions for our company. To access the program, simply click the ║
+║ button at the bottom of this email. We look forward to working with you and ║
+║ supporting you in your new role. ║
+║ ║
+║ Sincerely, ║
+║ The board of directors of Oligopoly Investments ║
+╚════════════════════════════════════════════════════════════════════════════════╝
+");
await Console.Write("Press any key to continue...");
Console.CursorVisible = false;
CloseRequested = CloseRequested || (await Console.ReadKey(true)).Key is ConsoleKey.Escape;
- await InitializeGame();
+ await DisplayGameModeScreen();
+ switch (GameMode)
+ {
+ case "default":
+ await DisplayDifficultiesScreen();
+ await InitializeGame();
+ break;
+ case "random":
+ LoadEmbeddedResources();
+ foreach (Company company in Companies)
+ {
+ company.SharePrice = Random.Shared.Next(100, 5001);
+ }
+ Money = Random.Shared.Next(1000, 30001);
+ LosingNetWorth = 2000.00M;
+ WinningNetWorth = 50000.00M;
+ break;
+ }
await GameLoop();
}
async Task PlayerWinsScreen()
{
await Console.Clear();
- await Console.WriteLine();
- await Console.WriteLine(" ┌────────────────────────────────────────────────────────────────────────────────┐");
- await Console.WriteLine(" │ Dear CEO, │");
- await Console.WriteLine(" │ │");
- await Console.WriteLine(" │ On behalf of the board of directors of Oligopoly Investments, we would like to │");
- await Console.WriteLine(" │ express our gratitude and understanding for your decision to leave your post. │");
- await Console.WriteLine(" │ You have been a remarkable leader and a visionary strategist, who played the │");
- await Console.WriteLine(" │ stock market skillfully and increased our budget by five times. We are proud │");
- await Console.WriteLine(" │ of your achievements and we wish you all the best in your future endeavors. As │");
- await Console.WriteLine(" │ a token of our appreciation, we are pleased to inform you that the company │");
- await Console.WriteLine(" │ will pay you a bonus of $1 million. You deserve this reward for your hard work │");
- await Console.WriteLine(" │ and dedication. We hope you will enjoy it and remember us fondly. Thank you │");
- await Console.WriteLine(" │ for your service and your contribution to Oligopoly Investments. │");
- await Console.WriteLine(" │ You will be missed. │");
- await Console.WriteLine(" │ │");
- await Console.WriteLine(" │ Sincerely, │");
- await Console.WriteLine(" │ The board of directors of Oligopoly Investments │");
- await Console.WriteLine(" └────────────────────────────────────────────────────────────────────────────────┘");
- await Console.WriteLine();
- await Console.WriteLine($"Your net worth is over {WinningNetWorth:C}.");
- await Console.WriteLine();
- await Console.WriteLine("You win! Congratulations!");
- await Console.WriteLine();
+ await Console.WriteLine(@$"
+ ██╗ ██╗ ██████╗ ██╗ ██╗ ██╗ ██╗██╗███╗ ██╗
+ ╚██╗ ██╔╝██╔═══██╗██║ ██║ ██║ ██║██║████╗ ██║
+ ╚████╔╝ ██║ ██║██║ ██║ ██║ █╗ ██║██║██╔██╗ ██║
+ ╚██╔╝ ██║ ██║██║ ██║ ██║███╗██║██║██║╚██╗██║
+ ██║ ╚██████╔╝╚██████╔╝ ╚███╔███╔╝██║██║ ╚████║
+ ╚═╝ ╚═════╝ ╚═════╝ ╚══╝╚══╝ ╚═╝╚═╝ ╚═══╝
+╔════════════════════════════════════════════════════════════════════════════════╗
+║ Dear CEO, ║
+║ ║
+║ On behalf of the board of directors of Oligopoly Investments, we would like to ║
+║ express our gratitude and understanding for your decision to leave your post. ║
+║ You have been a remarkable leader and a visionary strategist, who played the ║
+║ stock market skillfully and increased our budget by five times. We are proud ║
+║ of your achievements and we wish you all the best in your future endeavors. As ║
+║ a token of our appreciation, we are pleased to inform you that the company ║
+║ will pay you a bonus of $1 million. You deserve this reward for your hard work ║
+║ and dedication. We hope you will enjoy it and remember us fondly. Thank you ║
+║ for your service and your contribution to Oligopoly Investments. ║
+║ You will be missed. ║
+║ ║
+║ Sincerely, ║
+║ The board of directors of Oligopoly Investments ║
+╚════════════════════════════════════════════════════════════════════════════════╝
+
+Your Net Worth is over {WinningNetWorth}$
+You have played {TurnCounter} turns
+Congratulations!
+");
await Console.Write("Press any key (except ENTER) to continue...");
ConsoleKey key = ConsoleKey.Enter;
while (!CloseRequested && key is ConsoleKey.Enter)
@@ -324,25 +478,31 @@ async Task PlayerWinsScreen()
async Task PlayerLosesScreen()
{
await Console.Clear();
- await Console.WriteLine();
- await Console.WriteLine(" ┌────────────────────────────────────────────────────────────────────────────────┐");
- await Console.WriteLine(" │ Dear former CEO, │");
- await Console.WriteLine(" │ │");
- await Console.WriteLine(" │ We regret to inform you that you are being removed from the position of CEO │");
- await Console.WriteLine(" │ and fired from the company, effective immediately. The board of directors of │");
- await Console.WriteLine(" │ Oligopoly Investments has decided to take this action because you have spent │");
- await Console.WriteLine(" │ the budget allocated to you, and your investment turned out to be unprofitable │");
- await Console.WriteLine(" │ for the company. We appreciate your service and wish you all the best in your │");
- await Console.WriteLine(" │ future endeavors. │");
- await Console.WriteLine(" │ │");
- await Console.WriteLine(" │ Sincerely, │");
- await Console.WriteLine(" │ The board of directors of Oligopoly Investments │");
- await Console.WriteLine(" └────────────────────────────────────────────────────────────────────────────────┘");
- await Console.WriteLine();
- await Console.WriteLine($"Your net worth dropped below {LosingNetWorth:C}.");
- await Console.WriteLine();
- await Console.WriteLine("You Lose! Better luck next time...");
- await Console.WriteLine();
+ await Console.WriteLine($@"
+ ██╗ ██╗ ██████╗ ██╗ ██╗ ██╗ ██████╗ ███████╗███████╗
+ ╚██╗ ██╔╝██╔═══██╗██║ ██║ ██║ ██╔═══██╗██╔════╝██╔════╝
+ ╚████╔╝ ██║ ██║██║ ██║ ██║ ██║ ██║███████╗█████╗
+ ╚██╔╝ ██║ ██║██║ ██║ ██║ ██║ ██║╚════██║██╔══╝
+ ██║ ╚██████╔╝╚██████╔╝ ███████╗╚██████╔╝███████║███████╗
+ ╚═╝ ╚═════╝ ╚═════╝ ╚══════╝ ╚═════╝ ╚══════╝╚══════╝
+╔════════════════════════════════════════════════════════════════════════════════╗
+║ Dear former CEO, ║
+║ ║
+║ We regret to inform you that you are being removed from the position of CEO ║
+║ and fired from the company, effective immediately. The board of directors of ║
+║ Oligopoly Investments has decided to take this action because you have spent ║
+║ the budget allocated to you, and your investment turned out to be unprofitable ║
+║ for the company. We appreciate your service and wish you all the best in your ║
+║ future endeavors. ║
+║ ║
+║ Sincerely, ║
+║ The board of directors of Oligopoly Investments ║
+╚════════════════════════════════════════════════════════════════════════════════╝
+
+Your Net Worth dropped below {LosingNetWorth}$
+You have played {TurnCounter} turns
+Better luck next time...
+");
await Console.Write("Press any key (except ENTER) to continue...");
ConsoleKey key = ConsoleKey.Enter;
while (!CloseRequested && key is ConsoleKey.Enter)
@@ -356,15 +516,20 @@ async Task PlayerLosesScreen()
async Task AboutInfoScreen()
{
await Console.Clear();
- await Console.WriteLine();
- await Console.WriteLine(" |");
- await Console.WriteLine(" | THANKS!");
- await Console.WriteLine(" |");
- await Console.WriteLine(" | No really, thank you for taking time to play this simple console game. It means a lot.");
- await Console.WriteLine(" |");
- await Console.WriteLine(" | This game was created by Semion Medvedev (Fuinny)");
- await Console.WriteLine(" |");
- await Console.WriteLine();
+ await Console.WriteLine($@"
+ ████████╗██╗ ██╗ █████╗ ███╗ ██╗██╗ ██╗███████╗██╗
+ ╚══██╔══╝██║ ██║██╔══██╗████╗ ██║██║ ██╔╝██╔════╝██║
+ ██║ ███████║███████║██╔██╗ ██║█████╔╝ ███████╗██║
+ ██║ ██╔══██║██╔══██║██║╚██╗██║██╔═██╗ ╚════██║╚═╝
+ ██║ ██║ ██║██║ ██║██║ ╚████║██║ ██╗███████║██╗
+ ╚═╝ ╚═╝ ╚═╝╚═╝ ╚═╝╚═╝ ╚═══╝╚═╝ ╚═╝╚══════╝╚═╝
+╔══════════════════════════════════════════════════════════════════════════════════╗
+║No really, thank you for taking time to play this simple CLI game. It means a lot.║
+║If you find any bug or have an idea how to improve the game, please let me know :D║
+║ ║
+║This game was created by Semion Medvedev (Fuinny) ║
+╚══════════════════════════════════════════════════════════════════════════════════╝
+");
await Console.WriteLine("Press any key to continue...");
Console.CursorVisible = false;
CloseRequested = CloseRequested || (await Console.ReadKey(true)).Key is ConsoleKey.Escape;
@@ -376,19 +541,19 @@ StringBuilder RenderCompanyStocksTable()
const int c0 = 30, c1 = 10, c2 = 19, c3 = 17;
StringBuilder gameView = new();
- gameView.AppendLine($"╔═{new('═', c0)}═╤═{new('═', c1)}═╤═{new('═', c2)}═╤═{new('═', c3)}═╗");
- gameView.AppendLine($"║ {"Company",-c0} │ {"Industry",c1} │ {"Share Price",c2} │ {"You Have",c3} ║");
- gameView.AppendLine($"╟─{new('─', c0)}─┼─{new('─', c1)}─┼─{new('─', c2)}─┼─{new('─', c3)}─╢");
+ gameView.AppendLine($"╔═{new('═', c0)}═╦═{new('═', c1)}═╦═{new('═', c2)}═╦═{new('═', c3)}═╗");
+ gameView.AppendLine($"║ {"Company",-c0} ║ {"Industry",c1} ║ {"Share Price",c2} ║ {"You Have",c3} ║");
+ gameView.AppendLine($"╠═{new('═', c0)}═╬═{new('═', c1)}═╬═{new('═', c2)}═╬═{new('═', c3)}═╣");
foreach (Company company in Companies)
{
- gameView.AppendLine($"║ {company.Name,-c0} │ {company.Industry,c1} │ {company.SharePrice,c2:C} │ {company.NumberOfShares,c3} ║");
+ gameView.AppendLine($"║ {company.Name,-c0} ║ {company.Industry,c1} ║ {company.SharePrice,c2:C} ║ {company.NumberOfShares,c3} ║");
}
- gameView.AppendLine($"╚═{new('═', c0)}═╧═{new('═', c1)}═╧═{new('═', c2)}═╧═{new('═', c3)}═╝");
- gameView.AppendLine($"Your money: {Money:C} Your Net Worth: {CalculateNetWorth():C}");
+ gameView.AppendLine($"╚═{new('═', c0)}═╩═{new('═', c1)}═╩═{new('═', c2)}═╩═{new('═', c3)}═╝");
+ gameView.AppendLine($"Your money: {Money:C} Your Net Worth: {NetWorth:C} Current Turn: {TurnCounter}");
return gameView;
}
- async Task HandleMenuWithOptions(string prompt, string[] options)
+ async Task HandleMenuWithOptions(string prompt, string[] options, string[] descriptions = null!)
{
int index = 0;
ConsoleKey key = default;
@@ -410,6 +575,11 @@ async Task HandleMenuWithOptions(string prompt, string[] options)
await Console.WriteLine($"[ ] {currentOption}");
}
}
+ if (descriptions != null)
+ {
+ await Console.WriteLine("\nDescription:");
+ await Console.WriteLine(descriptions[index]);
+ }
Console.CursorVisible = false;
key = (await Console.ReadKey(true)).Key;
switch (key)
@@ -422,14 +592,32 @@ async Task HandleMenuWithOptions(string prompt, string[] options)
return index;
}
- decimal CalculateNetWorth()
+ void CalculateNetWorth()
{
- decimal netWorth = Money;
+ NetWorth = Money;
foreach (Company company in Companies)
{
- netWorth += company.SharePrice * company.NumberOfShares;
+ NetWorth += company.SharePrice * company.NumberOfShares;
+ }
+ }
+
+ void UpdateSharePrices()
+ {
+ for (int i = 0; i < Companies.Count; i++)
+ {
+ Random random = new Random();
+ int effect = random.Next(0, 2);
+
+ switch (effect)
+ {
+ case 0:
+ Companies[i].SharePrice += Companies[i].SharePrice * Random.Shared.Next(1, 4) / 100;
+ break;
+ case 1:
+ Companies[i].SharePrice += Companies[i].SharePrice * Random.Shared.Next(-3, 0) / 100;
+ break;
+ }
}
- return netWorth;
}
}
}
diff --git a/Projects/Website/GlobalEvent.json b/Projects/Website/GlobalEvent.json
new file mode 100644
index 00000000..09cd9f52
--- /dev/null
+++ b/Projects/Website/GlobalEvent.json
@@ -0,0 +1,32 @@
+[
+ {
+ "Title": "Government Investments",
+ "Description": "The government has announced a massive investment program aimed at stimulating economic growth and supporting key industries. Companies received significant amounts of money for further development. This had a positive impact on share prices and attracted many new investors.",
+ "Effect": 30
+ },
+ {
+ "Title": "Technological Breakthrough",
+ "Description": "A groundbreaking technological innovation has been announced, revolutionizing a particular industry or multiple sectors. This breakthrough has the potential to disrupt traditional business models, improve efficiency, and drive significant growth. Investors are optimistic about the future prospects of companies involved in the new technology, leading to a surge in their stock prices.",
+ "Effect": 30
+ },
+ {
+ "Title": "New Trade Agreements",
+ "Description": "A series of new trade agreements have been successfully negotiated between multiple countries, fostering increased international trade and cooperation. These agreements aim to reduce tariffs, eliminate trade barriers, and promote fair and balanced economic relationships. The market responds positively to the potential for expanded market access and improved trade conditions, leading to an increase in stock prices for companies involved in global trade and benefiting from the new trade agreements.",
+ "Effect": 30
+ },
+ {
+ "Title": "Government Regulation",
+ "Description": "A government has introduced new regulations or policies that impact various industries. These regulations could include stricter environmental standards, increased taxes, or limitations on certain business practices. The implementation of such regulations can lead to increased costs for companies and a decrease in their profitability, causing a decline in stock prices.",
+ "Effect": -30
+ },
+ {
+ "Title": "Major Earthquake",
+ "Description": "A catastrophic earthquake of significant magnitude has struck a region that is home to several major global companies. The earthquake has caused extensive damage to critical infrastructure, including manufacturing facilities, distribution centers, and transportation networks. This disruption severely impacts the operations and supply chains of these companies, leading to a decline in their stock prices. Additionally, the uncertainty surrounding the recovery and reconstruction efforts further contributes to investor concerns and market volatility.",
+ "Effect": -30
+ },
+ {
+ "Title": "Economic Crisis",
+ "Description": "A global economic crisis has emerged, marked by widespread financial instability, high unemployment rates, and decreased consumer confidence. The crisis is driven by a series of factors, including a sharp decline in business activity, reduced investment, and a contraction in international trade. Stock markets experience a significant downturn, leading to a decline in stock prices for companies across various sectors and a period of economic uncertainty and hardship.",
+ "Effect": 30
+ }
+]
\ No newline at end of file
diff --git a/Projects/Website/Resources.cs b/Projects/Website/Resources.cs
index 27ab3883..9b95a737 100644
--- a/Projects/Website/Resources.cs
+++ b/Projects/Website/Resources.cs
@@ -10,6 +10,7 @@ public static class Resources
public static readonly string[]? FiveLetterWords;
public static readonly string? Company_json;
public static readonly string? Event_json;
+ public static readonly string? GlobalEvent_json;
static Resources()
{
@@ -65,5 +66,15 @@ static Resources()
Event_json = streamReader.ReadToEnd();
}
}
+ {
+ const string name = "Website.GlobalEvent.json";
+ Assembly assembly = Assembly.GetExecutingAssembly();
+ using Stream stream = assembly.GetManifestResourceStream(name)!;
+ if (stream is not null)
+ {
+ using StreamReader streamReader = new(stream);
+ GlobalEvent_json = streamReader.ReadToEnd();
+ }
+ }
}
}
diff --git a/Projects/Website/Website.csproj b/Projects/Website/Website.csproj
index c289010c..aa51e62b 100644
--- a/Projects/Website/Website.csproj
+++ b/Projects/Website/Website.csproj
@@ -7,6 +7,7 @@
+
@@ -15,6 +16,7 @@
+