From cc1c4f4bdeec9906942514b9d710e66f8bff42be Mon Sep 17 00:00:00 2001 From: Semion Medvedev <126599206+Fuinny@users.noreply.github.com> Date: Wed, 10 May 2023 20:43:26 +0300 Subject: [PATCH 01/18] Added Oligopoly --- Projects/Oligopoly/Data/Data.xml | 392 ++++++++++++++++++++++++++ Projects/Oligopoly/Oligopoly.csproj | 16 ++ Projects/Oligopoly/Source/Company.cs | 136 +++++++++ Projects/Oligopoly/Source/Data.cs | 16 ++ Projects/Oligopoly/Source/Event.cs | 120 ++++++++ Projects/Oligopoly/Source/GameMenu.cs | 227 +++++++++++++++ Projects/Oligopoly/Source/Menu.cs | 115 ++++++++ Projects/Oligopoly/Source/Program.cs | 377 +++++++++++++++++++++++++ 8 files changed, 1399 insertions(+) create mode 100644 Projects/Oligopoly/Data/Data.xml create mode 100644 Projects/Oligopoly/Oligopoly.csproj create mode 100644 Projects/Oligopoly/Source/Company.cs create mode 100644 Projects/Oligopoly/Source/Data.cs create mode 100644 Projects/Oligopoly/Source/Event.cs create mode 100644 Projects/Oligopoly/Source/GameMenu.cs create mode 100644 Projects/Oligopoly/Source/Menu.cs create mode 100644 Projects/Oligopoly/Source/Program.cs diff --git a/Projects/Oligopoly/Data/Data.xml b/Projects/Oligopoly/Data/Data.xml new file mode 100644 index 00000000..9c2f356e --- /dev/null +++ b/Projects/Oligopoly/Data/Data.xml @@ -0,0 +1,392 @@ + + + + + Bingoo + BNG + Web + 1500 + Promising search company. Leader in the development of various web services and web applications. Bingoo is known for its innovative and user-friendly products that aim to make the web more accessible and enjoyable. Bingoo also invests in artificial intelligence and machine learning to enhance its search engine and other services. + + + Quantum Software + QST + Software + 2000 + Software development company. The company is best known for its own operating system and various software packages. Quantum Software is a pioneer in the field of software engineering and has a reputation for creating reliable and fast products. Quantum Software also collaborates with other companies and organizations to provide customized solutions for their needs. + + + Edison Incorporated + EDSN + Energy + 1000 + An innovative company engaged in the development and production of electric vehicles, batteries, solar panels. Edison Incorporated is a leader in the green energy sector and strives to reduce the environmental impact of transportation and energy consumption. Edison Incorporated also offers a range of services and products for consumers and businesses who want to switch to renewable energy sources. + + + Netfilm + NTF + Movies + 800 + A leading company in the field of online movies and series, also engaged in the development of video hosting. Netfilm is a popular platform for streaming and watching movies and series of various genres and languages. Netfilm also produces its own original content that attracts millions of viewers. Netfilm also provides a video hosting service that allows users to upload and share their own videos. + + + COBRA Security Consulting + CSC + Army + 1200 + 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. + + + + + 15 + BNG + Positive + Bingoo announcing their new search engine + The company has announced its new search engine that will be more productive and user-friendly than the previous one. The search engine also uses artificial intelligence technology to improve search results and provide personalized recommendations to users. Experts predict that this will increase the value of the company’s shares and attract more customers to its products and services. + + + 10 + BNG + Positive + Bingoo announcing their new AI assistant + Bingoo has unveiled its latest innovation: Bingy. An AI assistant that can chat, search, and create content for users. Bingy is powered by advanced natural language processing and machine learning technologies that enable it to understand and communicate fluently in multiple languages. Bingy is available as an application that users can install on their computers or phones for easy and convenient access. + + + 5 + BNG + Positive + Bingoo introduces new features and improvements for its web services + Bingoo has introduced a series of new features and improvements for its web services. The new features include voice search, image recognition, personalized recommendations, smart suggestions, faster loading times, better security and more. The updates apply to Bingoo's popular web services such as Bingoo Mail, Bingoo Cloud, Bingoo Maps, Bingoo News and others. + + + 5 + BNG + Positive + Bingoo creates a special event to attract more web developers + The event, called Bingoo Webathon, is a 24-hour online marathon of web development challenges, tutorials, demos and prizes. Bingoo said that the event is designed to showcase its web services and web applications and to inspire and motivate web developers of all levels and backgrounds to join its community and platform. + + + 5 + BNG + Positive + Bingoo wins industry award for innovative web services + Bingoo has won an industry award for its innovative and user-friendly web services, including its search engine and web applications. The award recognizes Bingoo's commitment to providing the best possible user experiences and staying at the forefront of technology trends. + + + 15 + BNG + Negative + Bingoo was accused of violating user privacy + The company was accused of stealing the personal data of its users and selling it to third parties without their consent. The case is currently under investigation by the authorities, but experts believe that this scandal will harm the company and its reputation. The company may face legal consequences and lose the trust of its users. + + + 10 + BNG + Negative + Bingoo's servers experience a service outage + Bingoo's services have been down for several hours due to a technical issue. Users have been unable to access their accounts, send emails, or use other Bingoo services during this time. The company has released a statement apologizing for the inconvenience and stating that it is working to resolve the issue as soon as possible. + + + 5 + BNG + Negative + Bingoo missed out on a lucrative acquisition deal + Bingoo was in talks to acquire a promising startup that could have helped the company expand its services and increase its market share. However, the company's management decided to abandon the deal at the last minute, citing concerns about the startup's financial health and market potential. This decision was criticized by shareholders and industry experts, who believe that Bingoo missed a valuable opportunity to grow its business and compete with its rivals. + + + 5 + BNG + Negative + Bingoo criticized for excessive advertising in its products + Bingoo has been heavily criticized by its users for the excessive amount of ads present in its search engine. Many users have complained that the ads are intrusive and negatively affect their experience with the product. This has led to a decrease in user satisfaction and may ultimately lead to a decrease in sales. + + + 5 + BNG + Negative + Bingoo terminates partnerships with phone manufacturers + Bingoo has announced that it will no longer be partnering with phone manufacturers to pre-install its search engine on their devices. This decision has been met with disappointment from phone manufacturers, as Bingoo's search engine is a popular choice among users. The move may lead to a decrease in Bingoo's market share and revenue, as users may choose other search engines instead. + + + 15 + QST + Positive + Quantum Software announces new operating system + The company has introduced its new operating system from the Qore OS family at a presentation event. The company claims that the new operating system is more reliable and faster than the competitors’ ones. The new operating system also has new features and functions that enhance the user experience. Experts expect the company’s share price to rise and the new operating system to become popular among users. + + + 10 + QST + Positive + Quantum Software announces update for Quantum Workflow + Quantum Software has just announced an exciting new update for its popular software package - Quantum Workflow. This new version is packed with innovative features and improvements that are sure to streamline your workflow and boost productivity. With its user-friendly interface and powerful capabilities, Quantum Workflow has already become a favorite among professionals in a variety of industries. + + + 5 + QST + Positive + Quantum Software presents its new development kit + The company has inoduced its new update for software development kit (QSDK). The new QSDK includes a powerful quantum simulator, a comprehensive set of libraries and frameworks, and a user-friendly development environment that makes it easy to get started with quantum programming. With QSDK developers also have access to new documnetation (QSDN), which will help them build robust and scalable applications. + + + 5 + QST + Positive + Quantum Software acquires a promising company + Quantum Software management has confirmed the purchase of a small software company. According to the company's management, the deal turned out to be very beneficial for both parties. The new software will soon be available on Quore OS operating systems and the company expects sales to increase in the near future. + + + 5 + QST + Positive + Quantum Software invests in Quantum Sky development + Quantum Software announced a major investment in the development of Quantum Sky, its cloud platform and infrastructure for creating innovative solutions in artificial intelligence, big data and internet of things. Quantum Sky aims to provide customers with access to the most advanced quantum computing resources and services, as well as to foster collaboration and innovation among researchers, developers and entrepreneurs. Quantum Software expects that Quantum Sky will boost its revenue and market share + + + 15 + QST + Negative + The Antimonopoly Commission accused Quantum Software of illegally maintaining its monopoly position + The Antimonopoly Commission announced that it has launched an investigation into Quantum Software. The commission claims that Quantum Software has abused its dominant position by engaging in unfair practices such as predatory pricing, exclusive contracts, and bundling products. The commission said that these practices have harmed consumers and competitors, and stifled innovation in the software market. The company said that it operates in a highly competitive and dynamic environment, and that its success is based on its superior products and services. + + + 10 + QST + Negative + Quantum Software reported a data breach + Some of the company’s servers were hacked by unknown attackers. The company is working with the police on this matter, but it is already known that their development of an unreleased operating system was stolen. The stolen data may contain sensitive information and secrets that could damage the company’s business. The company may also face legal action from its partners and customers who were affected by the breach. + + + 5 + QST + Negative + Users are unhappy with the latest Quore OS update + The latest update of Quore OS leads to numerous system breakdowns, and in some cases, loss of user data. Quantum Software has already apologized for the inconvenience and is working to remedy the situation. However, this event has caused many to consider alternative products, which could lead to a decrease in sales of Quantum Software. + + + 5 + QST + Negative + Quantum Software breaks partnership with driver manufacturer + Quantum Software management announced the termination of cooperation with one of the largest manufacturers of drivers for their systems. The reasons for this abrupt decision are not clear. The company said it is looking into alternative solutions to this problem. However, this may cause their operating systems to fall behind technically and reduce profits. + + + 5 + QST + Negative + Quantum Software faced mass layoffs + The company is facing massive layoffs. Employees say that before the release of the next major update, management began to set impossible tasks for them and give them the shortest possible time. The company's management has not yet commented on this, but this news will definitely not benefit the company's share prices. + + + 15 + EDSN + Positive + Edison Incorporated presents its new electric car + The company’s new electric cars with autopilot function went on sale in several countries. Edison Incorporated has managed to reduce the charging time of the car and increase its battery life by using innovative technology and materials. The first owners of electric cars are already leaving positive reviews and praising the performance and design of the car. The company expects to increase its sales and market share in the electric vehicle industry. + + + 10 + EDSN + Positive + Edison Incorporated enters the Asian market + The company has announced that it will start selling its electric vehicles in several Asian countries, including China, Japan, and India. The company said that it sees a huge potential for growth in these markets, as the demand for green and smart transportation is increasing. Edison Incorporated expects that this move will boost its sales and revenue, as well as its brand recognition and reputation. + + + 5 + EDSN + Positive + Edison Incorporated launches a successful advertising campaign + The company has launched a new advertising campaign to promote its electric vehicles and solar panels. The campaign features celebrities, influencers, and ordinary people who share their positive experiences with the company’s products and services. The campaign also highlights the environmental and economic benefits of switching to renewable energy sources. The campaign has received a lot of positive feedback and attention from the public and the media, and has increased the company’s popularity and customer loyalty. + + + 5 + EDSN + Positive + Edison Incorporated develops a more efficient electric engine + Edison Incorporated has developed a new electric engine that is more efficient and powerful than its previous models. The new engine uses less energy and produces less noise and emissions. The company said that the new engine will improve the performance and range of its electric vehicles, as well as reduce the maintenance costs and carbon footprint. The company plans to implement the new engine in its upcoming models and offer it as an upgrade option for existing customers. + + + 5 + EDSN + Positive + Edison Incorporated reduces the prices of its products + The company has announced that it will reduce the prices of its electric vehicles and solar panels by 10%. Edison Incorporated said that this decision is motivated by its desire to make its products more affordable and accessible to a wider range of customers. The company also said that it has achieved significant cost reductions thanks to its technological innovations and economies of scale. The price reduction is expected to increase the demand and sales of the company’s products, as well as its market share and competitiveness. + + + 15 + EDSN + Negative + Edison Incorporated is facing production difficulties + The company said it was having difficulty mining lithium, which is a key material for producing batteries for electric vehicles. The company blamed the shortage of lithium on environmental issues and political instability in some regions. Edison Incorporated assures that the difficulties are temporary and that it is looking for alternative sources of lithium. But we can already say that they harmed the company’s production and profits. + + + 10 + EDSN + Negative + Edison Incorporated recalls some of its electric vehicles + Edison Incorporated has announced that it will recall some of its electric vehicles due to a defect in the battery system that could cause overheating and fire. The company said that the recall affects a small percentage of its vehicles and that it will provide free repairs and replacements to the affected customers. The company apologized for the inconvenience and said that it is taking all the necessary measures to ensure the safety and quality of its products. However, this incident has damaged the company’s reputation and customer confidence. + + + 5 + EDSN + Negative + Edison Incorporated faces increased competition in the electric vehicle market + The company faces increased competition from other companies that are also producing and selling electric vehicles. Some of these competitors offer similar or better products at lower prices or with more features and options. The company said that it is confident in its products and services and that it will continue to innovate and improve its offerings. However, this may affect the company’s sales and market share, as customers may choose other alternatives. + + + 5 + EDSN + Negative + Customers criticize Edison Incorporated + The company has received some criticism from its customers who are unhappy with some aspects of its products and services. The customers have complained about the high prices, long delivery times, and poor customer service of the company. The company has responded to the criticism by acknowledging the issues and promising to improve its performance and quality. Edison Incorporated said that it values its customers’ feedback and that it will use it to enhance its products and services. The company hopes that this will restore its customer trust and satisfaction. + + + 5 + EDSN + Negative + Edison Incorporated reports problems with its autopilot system + The company has reported that some of its electric vehicles have experienced problems with their autopilot system. The system is supposed to assist the driver in steering, braking, and changing lanes, but some customers have reported that it has malfunctioned or failed to respond in some situations. Edison Incorporated said that it is investigating the cause of the problems and that it will issue a software update to fix them. The company also advised its customers to always pay attention and be ready to take over the control of the vehicle when using the autopilot system. The problems have raised some safety and reliability concerns among the customers and the regulators. + + + 15 + NTF + Positive + Netfilm announces new series + The company has confirmed the creation of its new series, which will be exclusive to its platform. The title and plot are still unknown, but the public already looks interested and curious. The company said that the new series will be a high-quality production with a talented cast and crew. The company hopes that the new series will attract more subscribers and viewers to its platform. + + + 10 + NTF + Positive + Netfilm wins awards for its original content + The company has won several awards for its original content, including movies and series. The awards recognize Netfilm’s creativity and excellence in producing and streaming high-quality content that appeals to a wide audience. The awards also boost Netfilm’s reputation and popularity in the online streaming industry. + + + 5 + NTF + Positive + Netfilm improves its video hosting service + Netfilm has announced that it has improved its video hosting service, which allows users to upload and stream their own videos on its platform. The company said that the improvement will enhance the quality, speed, and security of the video hosting service, as well as provide more options and features for users. The company said that the improvement will attract more users and creators to its platform, and increase its revenue and profit. + + + 5 + NTF + Positive + Netfilm offers a subscription discount + Netfilm has announced that it will offer a subscription discount for its customers who sign up for a year or more. The company said that the discount will make its service more affordable and accessible for its customers, as well as increase its customer loyalty and retention. The company said that the discount is part of its customer appreciation and promotion campaign. + + + 5 + NTF + Positive + Netfilm rewards its loyal customers + Netfilm has announced that it has rewarded its loyal customers with special offers and benefits. The company said that it has launched a loyalty program that allows its customers to earn points and redeem them for discounts, free trials, or exclusive content. The company also said that it has sent personalized recommendations and gifts to its customers, based on their preferences and interests. + + + 15 + NTF + Negative + Netfilm faced lawsuit + Netfilm sued by movie studios for streaming their content without permission. Netfilm denies the charges and says it has a fair use policy that allows it to stream content for educational and entertainment purposes. The lawsuit could affect the online streaming industry and set a precedent for future cases. The company may have to pay a large amount of money in damages or remove some content from its platform. + + + 10 + NTF + Negative + Netfilm delays new releases + Netfilm has announced that it will delay some of its new releases, due to production difficulties or quality issues. The company said that it wants to ensure that its new releases meet its high standards and expectations, and that it apologizes for any inconvenience caused to its customers. However, this decision has disappointed some of its customers who were eagerly waiting for the new releases, and has given an advantage to its competitors who have released their content on time. + + + 5 + NTF + Negative + Netfilm faces controversy over its content + Netfilm has faced controversy over some of its content, which has been accused of being offensive, inappropriate, or inaccurate. Some of its content has sparked backlash and criticism from various groups and individuals, who have demanded that Netfilm remove or apologize for the content. Some of its content has also been banned or censored in some countries or regions, due to legal or cultural reasons. This controversy has harmed Netfilm’s image and reputation, as well as caused some of its customers and partners to boycott or cancel its service. + + + 5 + NTF + Negative + Netfilm faces piracy threat + Netfilm has faced piracy threat, which has affected its revenue and profit. The company has discovered that some of its content has been illegally copied or distributed by unauthorized parties or platforms. The company has also found that some of its customers have shared their accounts or passwords with others, who have accessed its service without paying. The company said that it is taking measures to protect its intellectual property rights and to prevent piracy. However, this situation has reduced Netfilm’s income and market share, as well as damaged its exclusivity and value. + + + 5 + NTF + Negative + Netfilm faces employee strike + Netfilm has faced employee strike, which has disrupted its operations and productivity. The company’s employees have gone on strike to demand better working conditions, wages, and benefits. The company said that it is negotiating with the employees and their representatives, and that it hopes to reach a fair and reasonable agreement. However, this situation has affected Netfilm’s performance and output, as well as its relationship and trust with its employees. + + + 15 + CSC + Positive + COBRA Security Consulting signs a contract with the government + The company signed a contract with the government to ensure the security of state facilities such as military bases, power plants, airports, etc. COBRA operatives are already arriving at the facilities and setting up security measures. The exact amount of the contract was not disclosed, but it is already clear that the contract is beneficial to both parties. The contract will provide a stable income for the company and enhance the security of the state facilities. + + + 10 + CSC + Positive + The United Nations gives permission for COBRA Security Consulting to operate in new territories + The United Nations has granted permission for COBRA Security Consulting to operate in new territories that are under its supervision and protection. The permission allows the company to provide security services and solutions to various clients and sectors in these territories, such as humanitarian organizations, businesses, and governments. The company said that the permission is a sign of its credibility and reputation, as well as an opportunity to expand its scope and impact. + + + 5 + CSC + Positive + COBRA Security Consulting successfully completes the rescue operation + COBRA Security Consulting announced that it has successfully completed the rescue operation of a group of hostages held by a terrorist organization in a remote location. The operation involved a team of highly trained and experienced operatives who infiltrated the enemy camp and freed the hostages without any casualties. The hostages were then transported to a safe place and reunited with their families. The company said that the operation was a testament to its skills and dedication to saving lives. + + + 5 + CSC + Positive + COBRA Security Consulting unveils its new technology and equipment + COBRA Security Consulting unveils its new technology and equipment for its operatives. The new technology and equipment include advanced drones, sensors, weapons, and communication devices that enhance the capabilities and safety of its operatives. The company said that the new technology and equipment will give it an edge over its competitors and adversaries + + + 5 + CSC + Positive + COBRA Security Consulting secures a supply contract with government + COBRA Security Consulting revealed that it has provided security supplies to the government as part of a contract to equip its forces and agencies with the latest security equipment and technology. The contract will enhance the company’s revenue and reputation, as well as show its competence and dependability of its products and services. The company said that the contract is an acknowledgment of its innovation and excellence, and that it is pleased and honored to collaborate with the government. + + + 15 + CSC + Negative + COBRA Security Consulting is being criticized for their violent actions + COBRA Security Consulting has been criticized for its harsh actions in the Middle East on the territory of the facilities under its protection. The company’s management states that this is necessary to ensure security in the region and prevent terrorist attacks. However, some human rights organizations and media outlets accuse the company of using excessive force and violating international law. Government has already become interested in this case, and most likely the company will face punishment such as sanctions, fines, or termination of contracts. + + + 10 + CSC + Negative + COBRA Security Consulting brigades were captured + COBRA Security Consulting confirmed that some of its brigades were captured by a rebel group during a security operation. The brigades were part of a team that was providing security and escort to a convoy of humanitarian aid workers who were delivering supplies to a war-torn area. The rebel group ambushed the convoy and took the brigades as hostages. The company said that it is in contact with the rebel group and is negotiating for the release of the brigades. The company also said that it is doing everything in its power to ensure the safety and well-being of its brigades. + + + 5 + CSC + Negative + Fighter of COBRA Security Consulting was shot down + COBRA Security Consulting confirmed that one of its fighters was shot down by an unknown enemy during a security mission. The fighter was part of a team that was providing air support to a client who was under attack by a hostile force. The fighter was hit by a missile and crashed in a remote area. The company said that it is trying to locate and rescue the pilot, who is presumed to be alive. The company also said that it is investigating the identity and motive of the enemy who shot down the fighter. + + + 5 + CSC + Negative + COBRA Security Consulting vehicle involved in a deadly accident + A COBRA Security Consulting vehicle has been involved in a serious accident that resulted in several casualties, including civilians and company personnel. The accident happened during a convoy operation, and the cause of the accident is still under investigation. The company is offering support and compensation to the victims and their families, but it may face legal action and reputational damage from the incident. + + + 5 + CSC + Negative + COBRA Security Consulting staff arrested for illegal activity + 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's reputation and credibility, and it may face legal consequences if found guilty of any wrongdoing. + + + \ No newline at end of file diff --git a/Projects/Oligopoly/Oligopoly.csproj b/Projects/Oligopoly/Oligopoly.csproj new file mode 100644 index 00000000..57ad767c --- /dev/null +++ b/Projects/Oligopoly/Oligopoly.csproj @@ -0,0 +1,16 @@ + + + + Exe + net6.0 + enable + disable + + + + + Always + + + + diff --git a/Projects/Oligopoly/Source/Company.cs b/Projects/Oligopoly/Source/Company.cs new file mode 100644 index 00000000..13d78bb8 --- /dev/null +++ b/Projects/Oligopoly/Source/Company.cs @@ -0,0 +1,136 @@ +using System.Xml; +using System.Xml.Serialization; + +namespace Oligopoly.Source +{ + [XmlRoot("Company")] + public class Company + { + // Create a class fields. + private string name; + private string ticker; + private string industry; + private string description; + private double sharePrice; + private double shareAmount; + + [XmlElement("Name")] + public string Name + { + get + { + return name; + } + set + { + if (string.IsNullOrWhiteSpace(value)) + { + throw new InvalidOperationException("Name cannot be null or whitespace."); + } + else + { + name = value; + } + } + } + + [XmlElement("Ticker")] + public string Ticker + { + get + { + return ticker; + } + set + { + if (string.IsNullOrEmpty(value)) + { + throw new InvalidOperationException("Ticker cannot be null or whitespace."); + } + else + { + ticker = value; + } + } + } + + [XmlElement("Industry")] + public string Industry + { + get + { + return industry; + } + set + { + if (string.IsNullOrEmpty(value)) + { + throw new InvalidOperationException("Industry cannot be null of whitespace."); + } + else + { + industry = value; + } + } + } + + [XmlElement("SharePrice")] + public double SharePrice + { + get + { + return sharePrice; + } + set + { + if (value <= 0) + { + throw new InvalidOperationException("Share price cannot be less or equal to zero."); + } + else + { + sharePrice = value; + } + } + } + + public double ShareAmount + { + get + { + return shareAmount; + } + set + { + if (value < 0) + { + throw new InvalidOperationException("Share amount cannot be less than a zero."); + } + else + { + shareAmount = value; + } + } + } + + [XmlElement("Description")] + public string Description + { + get + { + return description; + } + set + { + if (string.IsNullOrEmpty(value)) + { + throw new InvalidOperationException("Description cannot be null or whitespace."); + } + else + { + description = value; + } + } + } + } +} \ No newline at end of file diff --git a/Projects/Oligopoly/Source/Data.cs b/Projects/Oligopoly/Source/Data.cs new file mode 100644 index 00000000..bbfcb467 --- /dev/null +++ b/Projects/Oligopoly/Source/Data.cs @@ -0,0 +1,16 @@ +using System.Xml.Serialization; + +namespace Oligopoly.Source +{ + [XmlRoot("Data")] + public class Data + { + [XmlArray("Companies")] + [XmlArrayItem("Company")] + public List gameCompanies { get; set; } + + [XmlArray("Events")] + [XmlArrayItem("Event")] + public List gameEvents { get; set; } + } +} \ No newline at end of file diff --git a/Projects/Oligopoly/Source/Event.cs b/Projects/Oligopoly/Source/Event.cs new file mode 100644 index 00000000..8ce4ba3a --- /dev/null +++ b/Projects/Oligopoly/Source/Event.cs @@ -0,0 +1,120 @@ +using System.Xml; +using System.Xml.Serialization; + +namespace Oligopoly.Source +{ + [XmlRoot("Events")] + public class Event + { + // Create a class fields. + private int effect; + private string target; + private string type; + private string title; + private string content; + + [XmlElement("Effect")] + public int Effect + { + get + { + return effect; + } + set + { + if (value <= 0) + { + throw new InvalidOperationException("Effect cannot be less or equal to zero."); + } + else + { + effect = value; + } + } + } + + [XmlElement("Target")] + public string Target + { + get + { + return target; + } + set + { + if (string.IsNullOrEmpty(value)) + { + throw new InvalidOperationException("Target cannot be null or whitespace."); + } + else + { + target = value; + } + } + } + + [XmlElement("Type")] + public string Type + { + get + { + return type; + } + set + { + if (string.IsNullOrEmpty(value)) + { + throw new InvalidOperationException("Type cannot be null or whitespace."); + } + else if (value != "Positive" && value != "Negative") + { + throw new InvalidOperationException("Type cannot contain value other then Positive or Negative"); + } + else + { + type = value; + } + } + } + + [XmlElement("Title")] + public string Title + { + get + { + return title; + } + set + { + if (string.IsNullOrEmpty(value)) + { + throw new InvalidOperationException("Title cannot be null or whitespace."); + } + else + { + title = value; + } + } + } + + [XmlElement("Content")] + public string Content + { + get + { + return content; + } + set + { + if (string.IsNullOrEmpty(value)) + { + throw new InvalidOperationException("Content cannot be null or whitespace."); + } + else + { + content = value; + } + } + } + } +} \ No newline at end of file diff --git a/Projects/Oligopoly/Source/GameMenu.cs b/Projects/Oligopoly/Source/GameMenu.cs new file mode 100644 index 00000000..9c581c9a --- /dev/null +++ b/Projects/Oligopoly/Source/GameMenu.cs @@ -0,0 +1,227 @@ +namespace Oligopoly.Source +{ + public class GameMenu : Menu + { + // Create a class fields. + private int CurrentEvent; + private double Money; + private Data Data; + + /// + /// Initializes a new instance of the GameMenu class with given parameters. + /// + /// The prompt to display above the menu. + /// The options to display in the menu. + /// The text output delay. Have to be a positive integer or zero. + /// The integer that represents current event. + /// The Data class object, which contains all companies and events. + public GameMenu(string prompt, string[] options, int outputDelay, int currentEvent, double money, Data data) + : base(prompt, options, outputDelay) + { + CurrentEvent = currentEvent; + Money = money; + Data = data; + } + + /// + /// Displays menu to the console and redraws it when user select other option. + /// + protected override void DisplayMenu() + { + // Display amount of money. + Console.WriteLine(string.Format($"You have: {Math.Round(Money, 2)}$\n", -50)); + + // Display current event. + Console.WriteLine($"{Data.gameEvents[CurrentEvent].Title}"); + Console.WriteLine($"\n{Data.gameEvents[CurrentEvent].Content}\n"); + + // Display companies. + Console.Write("╔"); + for (int i = 0; i < 120 - 2; i++) + { + Console.Write("═"); + } + Console.WriteLine("╗"); + + Console.WriteLine(string.Format($"{"║ Company",-52} ║ {"Ticker",8} ║ {"Industry",10} ║ {"Share Price",19} ║ {"You Have",17} ║")); + + Console.Write("╚"); + for (int i = 0; i < 120 - 2; i++) + { + Console.Write("═"); + } + Console.WriteLine("╝"); + + Console.Write("╔"); + for (int i = 0; i < 120 - 2; i++) + { + Console.Write("═"); + } + Console.WriteLine("╗"); + + foreach (var company in Data.gameCompanies) + { + Console.WriteLine(string.Format($"║ {company.Name,-50} ║ {company.Ticker,8} ║ {company.Industry,10} ║ {company.SharePrice,19} ║ {company.ShareAmount,17} ║")); + } + + Console.Write("╚"); + for (int i = 0; i < 120 - 2; i++) + { + Console.Write("═"); + } + Console.WriteLine("╝"); + + // Display the prompt above the menu. + foreach (char symbol in Prompt) + { + Thread.Sleep(OutputDelay); + Console.Write(symbol); + } + + // Display all options inside the menu and redraw it when user select other option. + for (int i = 0; i < Options.Length; i++) + { + string currentOption = Options[i]; + string prefix; + + if (i == SelectedIndex) + { + prefix = "*"; + Console.ForegroundColor = ConsoleColor.Black; + Console.BackgroundColor = ConsoleColor.White; + } + else + { + prefix = " "; + Console.ForegroundColor = ConsoleColor.White; + Console.BackgroundColor = ConsoleColor.Black; + } + + Console.WriteLine($"[{prefix}] {currentOption}"); + } + + Console.ResetColor(); + } + + /// + /// Runs the menu. + /// + /// An integer that represents the selected option. + public override int RunMenu() + { + // Set output delay to 0. + // This is necessary so that the menu does not draw with a delay when updating the console. + OutputDelay = 0; + + // Create variable, that contains key that was pressed. + ConsoleKey keyPressed; + + do + { + // Redraw the menu. + Console.Clear(); + DisplayMenu(); + + //Read the user's input. + ConsoleKeyInfo keyInfo = Console.ReadKey(); + + // Get the key that was pressed. + keyPressed = keyInfo.Key; + + // Move the selection up or down, based on the pressed key. + if (keyPressed == ConsoleKey.UpArrow) + { + SelectedIndex--; + + // Wrap around if user is out of range. + if (SelectedIndex == -1) + { + SelectedIndex = Options.Length - 1; + } + } + else if (keyPressed == ConsoleKey.DownArrow) + { + SelectedIndex++; + + // Wrap around if user is out of range. + if (SelectedIndex == Options.Length) + { + SelectedIndex = 0; + } + } + } while (keyPressed != ConsoleKey.Enter); + + // Return the selected option. + return SelectedIndex; + } + + /// + /// Runs the amount menu. + /// + /// An integer, that represents the amount of shares. + public int RunAmountMenu() + { + // Set output delay to 0. + // This is necessary so that the menu does not draw with a delay when updating the console. + OutputDelay = 0; + + // Create variable, that contains key that was pressed. + ConsoleKey keyPressed; + + int amount = 0; + + do + { + // Redraw the menu. + Console.Clear(); + DisplayMenu(); + + // Display current amount of shares. + Console.WriteLine($"Current amount: {amount}"); + + //Read the user's input. + ConsoleKeyInfo keyInfo = Console.ReadKey(); + + // Get the key that was pressed. + keyPressed = keyInfo.Key; + + // Move the selection up or down, based on the pressed key. + if (keyPressed == ConsoleKey.UpArrow) + { + SelectedIndex--; + + // Wrap around if user is out of range. + if (SelectedIndex == -1) + { + SelectedIndex = Options.Length - 1; + } + } + else if (keyPressed == ConsoleKey.DownArrow) + { + SelectedIndex++; + + // Wrap around if user is out of range. + if (SelectedIndex == Options.Length) + { + SelectedIndex = 0; + } + } + + if (keyPressed == ConsoleKey.Enter && SelectedIndex == 0) + { + amount++; + } + else if (keyPressed == ConsoleKey.Enter && SelectedIndex == 1) + { + if (amount > 0) + { + amount--; + } + } + } while (!(keyPressed == ConsoleKey.Enter && SelectedIndex == 2)); + + // Return the amount of shares. + return amount; + } + } +} \ No newline at end of file diff --git a/Projects/Oligopoly/Source/Menu.cs b/Projects/Oligopoly/Source/Menu.cs new file mode 100644 index 00000000..a9c99b15 --- /dev/null +++ b/Projects/Oligopoly/Source/Menu.cs @@ -0,0 +1,115 @@ +namespace Oligopoly.Source +{ + public class Menu + { + // Create a class fields. + protected int SelectedIndex; + protected int OutputDelay; + protected string Prompt; + protected string[] Options; + + /// + /// Initializes a new instance of the Menu class with given prompt, options and output delay. + /// + /// The prompt to display above the menu. + /// The options to display in the menu. + /// The text output delay. Have to be a positive integer or zero! + public Menu(string prompt, string[] options, int outputDelay) + { + Prompt = prompt; + Options = options; + OutputDelay = outputDelay; + SelectedIndex = 0; + } + + /// + /// Displays menu to the console and redraws it when user select other option. + /// + protected virtual void DisplayMenu() + { + // Display the prompt above the menu. + foreach (char symbol in Prompt) + { + Thread.Sleep(OutputDelay); + Console.Write(symbol); + } + + // Display all options inside the menu and redraw it when user select other option. + for (int i = 0; i < Options.Length; i++) + { + string currentOption = Options[i]; + string prefix; + + if (i == SelectedIndex) + { + prefix = "*"; + Console.ForegroundColor = ConsoleColor.Black; + Console.BackgroundColor = ConsoleColor.White; + } + else + { + prefix = " "; + Console.ForegroundColor = ConsoleColor.White; + Console.BackgroundColor = ConsoleColor.Black; + } + + Console.WriteLine($"[{prefix}] {currentOption}"); + } + + // Reset console colors. + Console.ResetColor(); + } + + /// + /// Runs the menu. + /// + /// An integer that represents the selected option. + public virtual int RunMenu() + { + // Set output delay to 0. + // This is necessary so that the menu does not draw with a delay when updating the console. + OutputDelay = 0; + + // Create variable, that contains key that was pressed. + ConsoleKey keyPressed; + + do + { + // Redraw the menu. + Console.Clear(); + DisplayMenu(); + + //Read the user's input. + ConsoleKeyInfo keyInfo = Console.ReadKey(); + + // Get the key that was pressed. + keyPressed = keyInfo.Key; + + // Move the selection up or down, based on the pressed key. + if (keyPressed == ConsoleKey.UpArrow) + { + SelectedIndex--; + + // Wrap around if user is out of range. + if (SelectedIndex == -1) + { + SelectedIndex = Options.Length - 1; + } + } + else if (keyPressed == ConsoleKey.DownArrow) + { + SelectedIndex++; + + // Wrap around if user is out of range. + if (SelectedIndex == Options.Length) + { + SelectedIndex = 0; + } + } + } while (keyPressed != ConsoleKey.Enter); + + // Return the selected option. + return SelectedIndex; + } + } +} \ No newline at end of file diff --git a/Projects/Oligopoly/Source/Program.cs b/Projects/Oligopoly/Source/Program.cs new file mode 100644 index 00000000..066b3a61 --- /dev/null +++ b/Projects/Oligopoly/Source/Program.cs @@ -0,0 +1,377 @@ +using System.Xml; +using System.Xml.Serialization; + +namespace Oligopoly.Source +{ + public class Program + { + /// + /// Program entry point. + /// + /// The array of strings to process. + public static void Main(string[] args) + { + RunMainMenu(); + } + + /// + /// Runs the main menu of the game. + /// + private static void RunMainMenu() + { + string prompt = @" + ██████╗ ██╗ ██╗ ██████╗ ██████╗ ██████╗ ██████╗ ██╗ ██╗ ██╗ +██╔═══██╗██║ ██║██╔════╝ ██╔═══██╗██╔══██╗██╔═══██╗██║ ╚██╗ ██╔╝ +██║ ██║██║ ██║██║ ███╗██║ ██║██████╔╝██║ ██║██║ ╚████╔╝ +██║ ██║██║ ██║██║ ██║██║ ██║██╔═══╝ ██║ ██║██║ ╚██╔╝ +╚██████╔╝███████╗██║╚██████╔╝╚██████╔╝██║ ╚██████╔╝███████╗██║ + ╚═════╝ ╚══════╝╚═╝ ╚═════╝ ╚═════╝ ╚═╝ ╚═════╝ ╚══════╝╚═╝ + --Use up and down arrow keys to select an option-- +"; + string[] options = { "Play", "About", "Exit" }; + + Menu mainMenu = new Menu(prompt, options, 0); + + int selectedOption = mainMenu.RunMenu(); + + switch (selectedOption) + { + case 0: + RunSkipMenu(); + break; + case 1: + DisplayAboutInfo(); + RunMainMenu(); + break; + case 2: + ExitGame(); + break; + } + } + + /// + /// Runs skip menu. + /// + private static void RunSkipMenu() + { + string prompt = @"Welcome to Oligopoly! +Do you want to read the introductory letter or do you want to jump right into the gameplay? + +"; + string[] options = { "Read introductory letter", "Skip introductory letter" }; + + Menu skipMenu = new Menu(prompt, options, 0); + + int selectedOption = skipMenu.RunMenu(); + + switch (selectedOption) + { + case 0: + RunStartMenu(); + break; + case 1: + RunGameMenu(); + break; + } + } + + /// + /// Runs the start menu of the game. + /// + private static void RunStartMenu() + { + string prompt = @"Dear, new CEO + 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 + +"; + string[] options = { "Get Access" }; + + Menu startMenu = new Menu(prompt, options, 15); + + int selectedOption = startMenu.RunMenu(); + + switch (selectedOption) + { + case 0: + Console.Clear(); + RunGameMenu(); + break; + } + } + + /// + /// Runs the game menu. + /// + private static void RunGameMenu() + { + // Create a Data class object, that contains game companies and events. + Data data = new Data(); + + // Read the .xml file. + try + { + XmlSerializer serializer = new XmlSerializer(typeof(Data)); + + using (Stream stream = File.Open("Data\\Data.xml", FileMode.Open)) + { + using (StreamReader reader = new StreamReader(stream)) + { + data = (Data)serializer.Deserialize(reader); + } + } + } + catch (InvalidOperationException ex) + { + Console.WriteLine($"Error! In file Data.xml specified invalid value."); + + if (ex.InnerException != null) + { + Console.WriteLine(ex.InnerException.Message); + } + } + catch (Exception ex) + { + Console.WriteLine($"Error! \nDetails: {ex.Message}"); + } + + // Create variables. + int currentEvent; + double money = 10000; + bool isGameEnded = false; + + // Create a Random class object to generate event. + Random random = new Random(); + + // Start of the game cycle. + while (!isGameEnded) + { + // Generate event for current turn. + currentEvent = random.Next(0, data.gameEvents.Count); + + // Determine current event's type. + if (data.gameEvents[currentEvent].Type == "Positive") // If current event is positive. + { + foreach (var currentCompany in data.gameCompanies) + { + if (currentCompany.Ticker == data.gameEvents[currentEvent].Target) + { + currentCompany.SharePrice = Math.Round(currentCompany.SharePrice + currentCompany.SharePrice * data.gameEvents[currentEvent].Effect / 100, 2); + } + } + } + else if (data.gameEvents[currentEvent].Type == "Negative") // If current event is negative. + { + foreach (var currentCompany in data.gameCompanies) + { + if (currentCompany.Ticker == data.gameEvents[currentEvent].Target) + { + currentCompany.SharePrice = Math.Round(currentCompany.SharePrice - currentCompany.SharePrice * data.gameEvents[currentEvent].Effect / 100, 2); + } + } + } + + string prompt = "\nUse up and down arrow keys to select an option: \n"; + string[] options = { "Skip", "Buy", "Sell", "More About Companies" }; + GameMenu gameMenu = new GameMenu(prompt, options, 0, currentEvent, money, data); + + int selectedOption = gameMenu.RunMenu(); + + switch (selectedOption) + { + case 0: + break; + case 1: + RunActionMenu(ref money, currentEvent, data, true); + break; + case 2: + RunActionMenu(ref money, currentEvent, data, false); + break; + case 3: + DisplayMoreAboutCompaniesMenu(data); + gameMenu.RunMenu(); + break; + } + + // Check for win or loss. + if (money <= 0) + { + isGameEnded = true; + RunEndMenu(false); + } + else if (money >= 50000) + { + isGameEnded = true; + RunEndMenu(true); + } + else + { + continue; + } + } + } + + /// + /// Runs action menu, that is buying or selling menu. + /// + /// The amount of money that user currently has. + /// The index of current generated event. + /// An Data class object, that contain information about companies and events. + /// Flag that determines the mode of the method. True - buying, false - selling. + private static void RunActionMenu(ref double money, int currentEvent, Data data, bool isBuying) + { + string actionPrompt = "Select a company: \n"; + string amountPrompt = "Select an amount: \n"; + string[] actionOptions = new string[data.gameCompanies.Count]; + string[] amountOptions = { "Increase (+)", "Decrease (-)", "Enter" }; + + for (int i = 0; i < actionOptions.Length; i++) + { + actionOptions[i] = data.gameCompanies[i].Name; + } + + GameMenu actionMenu = new GameMenu(actionPrompt, actionOptions, 0, currentEvent, money, data); + GameMenu amountMenu = new GameMenu(amountPrompt, amountOptions, 0, currentEvent, money, data); + + int selectedCompany = actionMenu.RunMenu(); + int amountOfShares = amountMenu.RunAmountMenu(); + + if (isBuying) + { + data.gameCompanies[selectedCompany].ShareAmount += amountOfShares; + money -= amountOfShares * data.gameCompanies[selectedCompany].SharePrice; + + Console.WriteLine($"You have bought {amountOfShares} shares of {data.gameCompanies[selectedCompany].Name} company."); + Thread.Sleep(2500); + } + else + { + if (amountOfShares <= data.gameCompanies[selectedCompany].ShareAmount) + { + data.gameCompanies[selectedCompany].ShareAmount -= amountOfShares; + money += amountOfShares * data.gameCompanies[selectedCompany].SharePrice; + + Console.WriteLine($"You have sold {amountOfShares} shares of {data.gameCompanies[selectedCompany].Name} company."); + Thread.Sleep(2500); + } + else + { + Console.WriteLine("Entered not a valid value"); + Thread.Sleep(2500); + } + } + } + + /// + /// Displays companies descriptions to the console. + /// + /// An Data class object, that contain information about companies and events. + private static void DisplayMoreAboutCompaniesMenu(Data data) + { + Console.Clear(); + + foreach (var company in data.gameCompanies) + { + Console.WriteLine($"{company.Name} - {company.Description}\n"); + } + + Console.WriteLine("Press any key to exit the menu..."); + Console.ReadKey(true); + } + + /// + /// Runs end menu. + /// + /// Flag that determines the mode of the method. True - for a winner, false - for a loser. + private static void RunEndMenu(bool isWinner) + { + Console.Clear(); + + if (isWinner) + { + string prompt = @"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 + +"; + string[] options = { "Play Again", "Return to Main Menu" }; + + Menu EndMenu = new Menu(prompt, options, 15); + + int selectedOption = EndMenu.RunMenu(); + + switch (selectedOption) + { + case 0: + RunGameMenu(); + break; + case 1: + RunMainMenu(); + break; + } + } + else + { + string prompt = @"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 + +"; + string[] options = { "Play Again", "Return to Main Menu" }; + + Menu EndMenu = new Menu(prompt, options, 15); + + int selectedOption = EndMenu.RunMenu(); + + switch (selectedOption) + { + case 0: + RunGameMenu(); + break; + case 1: + RunMainMenu(); + break; + } + } + } + + /// + /// Displays information about the game. + /// + private static void DisplayAboutInfo() + { + Console.Clear(); + Console.WriteLine(@"THANKS! +No really, thank you for taking time to play this simple console game. It means a lot. + +This game was created by Semion Medvedev (Fuinny) +My GitHub profile: https://github.com/Fuinny + +Press any key to exit the menu..."); + Console.ReadKey(true); + } + + /// + /// Exits the game. + /// + private static void ExitGame() + { + Console.Clear(); + Console.WriteLine("Press any key to exit the game..."); + Console.ReadKey(true); + Environment.Exit(0); + } + } +} \ No newline at end of file From ae837c661969b3cabc57099014b82c79c096aea6 Mon Sep 17 00:00:00 2001 From: ZacharyPatten Date: Wed, 10 May 2023 15:29:07 -0500 Subject: [PATCH 02/18] moved files and added to solution --- Projects/Oligopoly/{Source => }/Company.cs | 0 Projects/Oligopoly/{Source => }/Data.cs | 0 Projects/Oligopoly/{Data => }/Data.xml | 0 Projects/Oligopoly/{Source => }/Event.cs | 0 Projects/Oligopoly/{Source => }/GameMenu.cs | 0 Projects/Oligopoly/{Source => }/Menu.cs | 0 Projects/Oligopoly/Oligopoly.csproj | 25 +++++++++------------ Projects/Oligopoly/{Source => }/Program.cs | 0 dotnet-console-games.sln | 6 +++++ dotnet-console-games.slnf | 1 + 10 files changed, 18 insertions(+), 14 deletions(-) rename Projects/Oligopoly/{Source => }/Company.cs (100%) rename Projects/Oligopoly/{Source => }/Data.cs (100%) rename Projects/Oligopoly/{Data => }/Data.xml (100%) rename Projects/Oligopoly/{Source => }/Event.cs (100%) rename Projects/Oligopoly/{Source => }/GameMenu.cs (100%) rename Projects/Oligopoly/{Source => }/Menu.cs (100%) rename Projects/Oligopoly/{Source => }/Program.cs (100%) diff --git a/Projects/Oligopoly/Source/Company.cs b/Projects/Oligopoly/Company.cs similarity index 100% rename from Projects/Oligopoly/Source/Company.cs rename to Projects/Oligopoly/Company.cs diff --git a/Projects/Oligopoly/Source/Data.cs b/Projects/Oligopoly/Data.cs similarity index 100% rename from Projects/Oligopoly/Source/Data.cs rename to Projects/Oligopoly/Data.cs diff --git a/Projects/Oligopoly/Data/Data.xml b/Projects/Oligopoly/Data.xml similarity index 100% rename from Projects/Oligopoly/Data/Data.xml rename to Projects/Oligopoly/Data.xml diff --git a/Projects/Oligopoly/Source/Event.cs b/Projects/Oligopoly/Event.cs similarity index 100% rename from Projects/Oligopoly/Source/Event.cs rename to Projects/Oligopoly/Event.cs diff --git a/Projects/Oligopoly/Source/GameMenu.cs b/Projects/Oligopoly/GameMenu.cs similarity index 100% rename from Projects/Oligopoly/Source/GameMenu.cs rename to Projects/Oligopoly/GameMenu.cs diff --git a/Projects/Oligopoly/Source/Menu.cs b/Projects/Oligopoly/Menu.cs similarity index 100% rename from Projects/Oligopoly/Source/Menu.cs rename to Projects/Oligopoly/Menu.cs diff --git a/Projects/Oligopoly/Oligopoly.csproj b/Projects/Oligopoly/Oligopoly.csproj index 57ad767c..d011dcfd 100644 --- a/Projects/Oligopoly/Oligopoly.csproj +++ b/Projects/Oligopoly/Oligopoly.csproj @@ -1,16 +1,13 @@  - - - Exe - net6.0 - enable - disable - - - - - Always - - - + + Exe + net6.0 + enable + disable + + + + Always + + diff --git a/Projects/Oligopoly/Source/Program.cs b/Projects/Oligopoly/Program.cs similarity index 100% rename from Projects/Oligopoly/Source/Program.cs rename to Projects/Oligopoly/Program.cs diff --git a/dotnet-console-games.sln b/dotnet-console-games.sln index 5864a44b..4ac112b6 100644 --- a/dotnet-console-games.sln +++ b/dotnet-console-games.sln @@ -91,6 +91,8 @@ Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Checkers", "Projects\Checke EndProject Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Console Monsters", "Projects\Console Monsters\Console Monsters.csproj", "{9DA287B7-0532-4CAD-987E-A8633B6532F3}" EndProject +Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Oligopoly", "Projects\Oligopoly\Oligopoly.csproj", "{E5065B85-6951-4AC8-940C-339FFD2EEE7E}" +EndProject Global GlobalSection(SolutionConfigurationPlatforms) = preSolution Debug|Any CPU = Debug|Any CPU @@ -273,6 +275,10 @@ Global {9DA287B7-0532-4CAD-987E-A8633B6532F3}.Debug|Any CPU.Build.0 = Debug|Any CPU {9DA287B7-0532-4CAD-987E-A8633B6532F3}.Release|Any CPU.ActiveCfg = Release|Any CPU {9DA287B7-0532-4CAD-987E-A8633B6532F3}.Release|Any CPU.Build.0 = Release|Any CPU + {E5065B85-6951-4AC8-940C-339FFD2EEE7E}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {E5065B85-6951-4AC8-940C-339FFD2EEE7E}.Debug|Any CPU.Build.0 = Debug|Any CPU + {E5065B85-6951-4AC8-940C-339FFD2EEE7E}.Release|Any CPU.ActiveCfg = Release|Any CPU + {E5065B85-6951-4AC8-940C-339FFD2EEE7E}.Release|Any CPU.Build.0 = Release|Any CPU EndGlobalSection GlobalSection(SolutionProperties) = preSolution HideSolutionNode = FALSE diff --git a/dotnet-console-games.slnf b/dotnet-console-games.slnf index c2ec291c..4b27fd15 100644 --- a/dotnet-console-games.slnf +++ b/dotnet-console-games.slnf @@ -24,6 +24,7 @@ "Projects\\Maze\\Maze.csproj", "Projects\\Memory\\Memory.csproj", "Projects\\Minesweeper\\Minesweeper.csproj", + "Projects\\Oligopoly\\Oligopoly.csproj", "Projects\\PacMan\\PacMan.csproj", "Projects\\Pong\\Pong.csproj", "Projects\\Quick Draw\\Quick Draw.csproj", From bc4533142368f83ff5ee5dc9a466c302dbe9f2b4 Mon Sep 17 00:00:00 2001 From: ZacharyPatten Date: Wed, 10 May 2023 15:42:25 -0500 Subject: [PATCH 03/18] workflow --- .github/workflows/Oligopoly Build.yml | 20 ++++++++++++++++++++ 1 file changed, 20 insertions(+) create mode 100644 .github/workflows/Oligopoly Build.yml diff --git a/.github/workflows/Oligopoly Build.yml b/.github/workflows/Oligopoly Build.yml new file mode 100644 index 00000000..ed2ee0d1 --- /dev/null +++ b/.github/workflows/Oligopoly Build.yml @@ -0,0 +1,20 @@ +name: Oligopoly Build +on: + push: + paths: + - 'Projects/Oligopoly/**' + pull_request: + paths: + - 'Projects/Oligopoly/**' + workflow_dispatch: +jobs: + build: + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v1 + - name: setup dotnet + uses: actions/setup-dotnet@v1 + with: + dotnet-version: 6.0.x + - name: dotnet build + run: dotnet build "Projects\Oligopoly\Oligopoly.csproj" --configuration Release From c528c6c8dda9855f95ca45c97ea967480ee78429 Mon Sep 17 00:00:00 2001 From: ZacharyPatten Date: Wed, 10 May 2023 15:42:37 -0500 Subject: [PATCH 04/18] vscode --- .vscode/launch.json | 10 ++++++++++ .vscode/tasks.json | 13 +++++++++++++ 2 files changed, 23 insertions(+) diff --git a/.vscode/launch.json b/.vscode/launch.json index 30d6a355..45aee06e 100644 --- a/.vscode/launch.json +++ b/.vscode/launch.json @@ -262,6 +262,16 @@ "console": "externalTerminal", "stopAtEntry": false, }, + { + "name": "Oligopoly", + "type": "coreclr", + "request": "launch", + "preLaunchTask": "Build Oligopoly", + "program": "${workspaceFolder}/Projects/Oligopoly/bin/Debug/Oligopoly.dll", + "cwd": "${workspaceFolder}/Projects/Oligopoly/bin/Debug", + "console": "externalTerminal", + "stopAtEntry": false, + }, { "name": "Yahtzee", "type": "coreclr", diff --git a/.vscode/tasks.json b/.vscode/tasks.json index b29a8b5e..dc9e1d00 100644 --- a/.vscode/tasks.json +++ b/.vscode/tasks.json @@ -561,6 +561,19 @@ ], "problemMatcher": "$msCompile", }, + { + "label": "Build Oligopoly", + "command": "dotnet", + "type": "process", + "args": + [ + "build", + "${workspaceFolder}/Projects/Oligopoly/Oligopoly.csproj", + "/property:GenerateFullPaths=true", + "/consoleloggerparameters:NoSummary", + ], + "problemMatcher": "$msCompile", + }, { "label": "Build Solution", "command": "dotnet", From e9205645462246e3253d630d143eafbf21d2460e Mon Sep 17 00:00:00 2001 From: ZacharyPatten Date: Wed, 10 May 2023 15:50:59 -0500 Subject: [PATCH 05/18] readmes --- Projects/Oligopoly/README.md | 38 ++++++++++++++++++++++++++++++++++++ README.md | 1 + 2 files changed, 39 insertions(+) create mode 100644 Projects/Oligopoly/README.md diff --git a/Projects/Oligopoly/README.md b/Projects/Oligopoly/README.md new file mode 100644 index 00000000..1388a3d1 --- /dev/null +++ b/Projects/Oligopoly/README.md @@ -0,0 +1,38 @@ +

+ Oligopoly +

+ +

+ flat + Language C# + Discord + +

+ +

+ You can play this game in your browser: +
+ + Play Now + +
+ Hosted On GitHub Pages +

+ +Oligopoly is a stock market betting game. Buy stocks in a company and then try to sell them at a higher price. + +## Input + +- `↑`, `↓`, `←`, `→`: movement +- `enter`: play again +- `escape`: exit game + +> resizing the console window will cause the game to close + +## Downloads + +[win-x64](https://github.com/dotnet/dotnet-console-games/raw/binaries/win-x64/Oligopoly.exe) + +[linux-x64](https://github.com/dotnet/dotnet-console-games/raw/binaries/linux-x64/Oligopoly) + +[osx-x64](https://github.com/dotnet/dotnet-console-games/raw/binaries/osx-x64/Oligopoly) diff --git a/README.md b/README.md index b5111fca..594d1e53 100644 --- a/README.md +++ b/README.md @@ -50,6 +50,7 @@ |[Hurdles](Projects/Hurdles)|3|[![Play Now](.github/resources/play-badge.svg)](https://dotnet.github.io/dotnet-console-games/Hurdles) [![Status](https://github.com/dotnet/dotnet-console-games/workflows/Hurdles%20Build/badge.svg)](https://github.com/dotnet/dotnet-console-games/actions)| |[Pong](Projects/Pong)|3|[![Play Now](.github/resources/play-badge.svg)](https://dotnet.github.io/dotnet-console-games/Pong) [![Status](https://github.com/dotnet/dotnet-console-games/workflows/Pong%20Build/badge.svg)](https://github.com/dotnet/dotnet-console-games/actions)| |[Flappy Bird](Projects/Flappy%20Bird)|3|[![Play Now](.github/resources/play-badge.svg)](https://dotnet.github.io/dotnet-console-games/Flappy%20Bird) [![Status](https://github.com/dotnet/dotnet-console-games/workflows/Flappy%20Bird%20Build/badge.svg)](https://github.com/dotnet/dotnet-console-games/actions)| +|[Oligopoly](Projects/Oligopoly)|3|[![Play Now](.github/resources/play-badge.svg)](https://dotnet.github.io/dotnet-console-games/Oligopoly) [![Status](https://github.com/dotnet/dotnet-console-games/workflows/Oligopoly%20Build/badge.svg)](https://github.com/dotnet/dotnet-console-games/actions)
*_[Community Contribution](https://github.com/dotnet/dotnet-console-games/pull/72)_| |[Yahtzee](Projects/Yahtzee)|4|[![Play Now](.github/resources/play-badge.svg)](https://dotnet.github.io/dotnet-console-games/Yahtzee) [![Status](https://github.com/dotnet/dotnet-console-games/workflows/Yahtzee%20Build/badge.svg)](https://github.com/dotnet/dotnet-console-games/actions)| |[Tanks](Projects/Tanks)|4|[![Play Now](.github/resources/play-badge.svg)](https://dotnet.github.io/dotnet-console-games/Tanks) [![Status](https://github.com/dotnet/dotnet-console-games/workflows/Tanks%20Build/badge.svg)](https://github.com/dotnet/dotnet-console-games/actions)| |[Helicopter](Projects/Helicopter)|4|[![Play Now](.github/resources/play-badge.svg)](https://dotnet.github.io/dotnet-console-games/Helicopter) [![Status](https://github.com/dotnet/dotnet-console-games/workflows/Helicopter%20Build/badge.svg)](https://github.com/dotnet/dotnet-console-games/actions)| From 7a837c48df7261ec26a80170916b3b6d7f778a5f Mon Sep 17 00:00:00 2001 From: ZacharyPatten Date: Wed, 10 May 2023 16:32:26 -0500 Subject: [PATCH 06/18] xml -> json minor style changes --- Projects/Oligopoly/Company.cs | 145 +-------- Projects/Oligopoly/Company.json | 42 +++ Projects/Oligopoly/Data.cs | 16 - Projects/Oligopoly/Data.xml | 392 ------------------------ Projects/Oligopoly/Event.cs | 128 +------- Projects/Oligopoly/Event.json | 352 ++++++++++++++++++++++ Projects/Oligopoly/GameMenu.cs | 446 ++++++++++++++-------------- Projects/Oligopoly/Menu.cs | 225 +++++++------- Projects/Oligopoly/Oligopoly.csproj | 11 +- Projects/Oligopoly/Program.cs | 131 ++++---- 10 files changed, 813 insertions(+), 1075 deletions(-) create mode 100644 Projects/Oligopoly/Company.json delete mode 100644 Projects/Oligopoly/Data.cs delete mode 100644 Projects/Oligopoly/Data.xml create mode 100644 Projects/Oligopoly/Event.json diff --git a/Projects/Oligopoly/Company.cs b/Projects/Oligopoly/Company.cs index 13d78bb8..a19095f9 100644 --- a/Projects/Oligopoly/Company.cs +++ b/Projects/Oligopoly/Company.cs @@ -1,136 +1,13 @@ -using System.Xml; -using System.Xml.Serialization; +#nullable disable -namespace Oligopoly.Source -{ - [XmlRoot("Company")] - public class Company - { - // Create a class fields. - private string name; - private string ticker; - private string industry; - private string description; - private double sharePrice; - private double shareAmount; - - [XmlElement("Name")] - public string Name - { - get - { - return name; - } - set - { - if (string.IsNullOrWhiteSpace(value)) - { - throw new InvalidOperationException("Name cannot be null or whitespace."); - } - else - { - name = value; - } - } - } - - [XmlElement("Ticker")] - public string Ticker - { - get - { - return ticker; - } - set - { - if (string.IsNullOrEmpty(value)) - { - throw new InvalidOperationException("Ticker cannot be null or whitespace."); - } - else - { - ticker = value; - } - } - } - - [XmlElement("Industry")] - public string Industry - { - get - { - return industry; - } - set - { - if (string.IsNullOrEmpty(value)) - { - throw new InvalidOperationException("Industry cannot be null of whitespace."); - } - else - { - industry = value; - } - } - } +namespace Oligopoly; - [XmlElement("SharePrice")] - public double SharePrice - { - get - { - return sharePrice; - } - set - { - if (value <= 0) - { - throw new InvalidOperationException("Share price cannot be less or equal to zero."); - } - else - { - sharePrice = value; - } - } - } - - public double ShareAmount - { - get - { - return shareAmount; - } - set - { - if (value < 0) - { - throw new InvalidOperationException("Share amount cannot be less than a zero."); - } - else - { - shareAmount = value; - } - } - } - - [XmlElement("Description")] - public string Description - { - get - { - return description; - } - set - { - if (string.IsNullOrEmpty(value)) - { - throw new InvalidOperationException("Description cannot be null or whitespace."); - } - else - { - description = value; - } - } - } - } -} \ No newline at end of file +public class Company +{ + public string Name { get; set; } + public string Ticker { get; set; } + public string Industry { get; set; } + public double SharePrice { get; set; } + public double ShareAmount { get; set; } + public string Description { get; set; } +} diff --git a/Projects/Oligopoly/Company.json b/Projects/Oligopoly/Company.json new file mode 100644 index 00000000..5f170c57 --- /dev/null +++ b/Projects/Oligopoly/Company.json @@ -0,0 +1,42 @@ +[ + { + "Name": "Bingoo", + "Ticker": "BNG", + "Industry": "Web", + "SharePrice": 1500, + "ShareAmount": 0, + "Description": "Promising search company. Leader in the development of various web services and web applications. Bingoo is known for its innovative and user-friendly products that aim to make the web more accessible and enjoyable. Bingoo also invests in artificial intelligence and machine learning to enhance its search engine and other services." + }, + { + "Name": "Quantum Software", + "Ticker": "QST", + "Industry": "Software", + "SharePrice": 2000, + "ShareAmount": 0, + "Description": "Software development company. The company is best known for its own operating system and various software packages. Quantum Software is a pioneer in the field of software engineering and has a reputation for creating reliable and fast products. Quantum Software also collaborates with other companies and organizations to provide customized solutions for their needs." + }, + { + "Name": "Edison Incorporated", + "Ticker": "EDSN", + "Industry": "Energy", + "SharePrice": 1000, + "ShareAmount": 0, + "Description": "An innovative company engaged in the development and production of electric vehicles, batteries, solar panels. Edison Incorporated is a leader in the green energy sector and strives to reduce the environmental impact of transportation and energy consumption. Edison Incorporated also offers a range of services and products for consumers and businesses who want to switch to renewable energy sources." + }, + { + "Name": "Netfilm", + "Ticker": "NTF", + "Industry": "Movies", + "SharePrice": 800, + "ShareAmount": 0, + "Description": "A leading company in the field of online movies and series, also engaged in the development of video hosting. Netfilm is a popular platform for streaming and watching movies and series of various genres and languages. Netfilm also produces its own original content that attracts millions of viewers. Netfilm also provides a video hosting service that allows users to upload and share their own videos." + }, + { + "Name": "COBRA Security Consulting", + "Ticker": "CSC", + "Industry": "Army", + "SharePrice": 1200, + "ShareAmount": 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." + } +] \ No newline at end of file diff --git a/Projects/Oligopoly/Data.cs b/Projects/Oligopoly/Data.cs deleted file mode 100644 index bbfcb467..00000000 --- a/Projects/Oligopoly/Data.cs +++ /dev/null @@ -1,16 +0,0 @@ -using System.Xml.Serialization; - -namespace Oligopoly.Source -{ - [XmlRoot("Data")] - public class Data - { - [XmlArray("Companies")] - [XmlArrayItem("Company")] - public List gameCompanies { get; set; } - - [XmlArray("Events")] - [XmlArrayItem("Event")] - public List gameEvents { get; set; } - } -} \ No newline at end of file diff --git a/Projects/Oligopoly/Data.xml b/Projects/Oligopoly/Data.xml deleted file mode 100644 index 9c2f356e..00000000 --- a/Projects/Oligopoly/Data.xml +++ /dev/null @@ -1,392 +0,0 @@ - - - - - Bingoo - BNG - Web - 1500 - Promising search company. Leader in the development of various web services and web applications. Bingoo is known for its innovative and user-friendly products that aim to make the web more accessible and enjoyable. Bingoo also invests in artificial intelligence and machine learning to enhance its search engine and other services. - - - Quantum Software - QST - Software - 2000 - Software development company. The company is best known for its own operating system and various software packages. Quantum Software is a pioneer in the field of software engineering and has a reputation for creating reliable and fast products. Quantum Software also collaborates with other companies and organizations to provide customized solutions for their needs. - - - Edison Incorporated - EDSN - Energy - 1000 - An innovative company engaged in the development and production of electric vehicles, batteries, solar panels. Edison Incorporated is a leader in the green energy sector and strives to reduce the environmental impact of transportation and energy consumption. Edison Incorporated also offers a range of services and products for consumers and businesses who want to switch to renewable energy sources. - - - Netfilm - NTF - Movies - 800 - A leading company in the field of online movies and series, also engaged in the development of video hosting. Netfilm is a popular platform for streaming and watching movies and series of various genres and languages. Netfilm also produces its own original content that attracts millions of viewers. Netfilm also provides a video hosting service that allows users to upload and share their own videos. - - - COBRA Security Consulting - CSC - Army - 1200 - 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. - - - - - 15 - BNG - Positive - Bingoo announcing their new search engine - The company has announced its new search engine that will be more productive and user-friendly than the previous one. The search engine also uses artificial intelligence technology to improve search results and provide personalized recommendations to users. Experts predict that this will increase the value of the company’s shares and attract more customers to its products and services. - - - 10 - BNG - Positive - Bingoo announcing their new AI assistant - Bingoo has unveiled its latest innovation: Bingy. An AI assistant that can chat, search, and create content for users. Bingy is powered by advanced natural language processing and machine learning technologies that enable it to understand and communicate fluently in multiple languages. Bingy is available as an application that users can install on their computers or phones for easy and convenient access. - - - 5 - BNG - Positive - Bingoo introduces new features and improvements for its web services - Bingoo has introduced a series of new features and improvements for its web services. The new features include voice search, image recognition, personalized recommendations, smart suggestions, faster loading times, better security and more. The updates apply to Bingoo's popular web services such as Bingoo Mail, Bingoo Cloud, Bingoo Maps, Bingoo News and others. - - - 5 - BNG - Positive - Bingoo creates a special event to attract more web developers - The event, called Bingoo Webathon, is a 24-hour online marathon of web development challenges, tutorials, demos and prizes. Bingoo said that the event is designed to showcase its web services and web applications and to inspire and motivate web developers of all levels and backgrounds to join its community and platform. - - - 5 - BNG - Positive - Bingoo wins industry award for innovative web services - Bingoo has won an industry award for its innovative and user-friendly web services, including its search engine and web applications. The award recognizes Bingoo's commitment to providing the best possible user experiences and staying at the forefront of technology trends. - - - 15 - BNG - Negative - Bingoo was accused of violating user privacy - The company was accused of stealing the personal data of its users and selling it to third parties without their consent. The case is currently under investigation by the authorities, but experts believe that this scandal will harm the company and its reputation. The company may face legal consequences and lose the trust of its users. - - - 10 - BNG - Negative - Bingoo's servers experience a service outage - Bingoo's services have been down for several hours due to a technical issue. Users have been unable to access their accounts, send emails, or use other Bingoo services during this time. The company has released a statement apologizing for the inconvenience and stating that it is working to resolve the issue as soon as possible. - - - 5 - BNG - Negative - Bingoo missed out on a lucrative acquisition deal - Bingoo was in talks to acquire a promising startup that could have helped the company expand its services and increase its market share. However, the company's management decided to abandon the deal at the last minute, citing concerns about the startup's financial health and market potential. This decision was criticized by shareholders and industry experts, who believe that Bingoo missed a valuable opportunity to grow its business and compete with its rivals. - - - 5 - BNG - Negative - Bingoo criticized for excessive advertising in its products - Bingoo has been heavily criticized by its users for the excessive amount of ads present in its search engine. Many users have complained that the ads are intrusive and negatively affect their experience with the product. This has led to a decrease in user satisfaction and may ultimately lead to a decrease in sales. - - - 5 - BNG - Negative - Bingoo terminates partnerships with phone manufacturers - Bingoo has announced that it will no longer be partnering with phone manufacturers to pre-install its search engine on their devices. This decision has been met with disappointment from phone manufacturers, as Bingoo's search engine is a popular choice among users. The move may lead to a decrease in Bingoo's market share and revenue, as users may choose other search engines instead. - - - 15 - QST - Positive - Quantum Software announces new operating system - The company has introduced its new operating system from the Qore OS family at a presentation event. The company claims that the new operating system is more reliable and faster than the competitors’ ones. The new operating system also has new features and functions that enhance the user experience. Experts expect the company’s share price to rise and the new operating system to become popular among users. - - - 10 - QST - Positive - Quantum Software announces update for Quantum Workflow - Quantum Software has just announced an exciting new update for its popular software package - Quantum Workflow. This new version is packed with innovative features and improvements that are sure to streamline your workflow and boost productivity. With its user-friendly interface and powerful capabilities, Quantum Workflow has already become a favorite among professionals in a variety of industries. - - - 5 - QST - Positive - Quantum Software presents its new development kit - The company has inoduced its new update for software development kit (QSDK). The new QSDK includes a powerful quantum simulator, a comprehensive set of libraries and frameworks, and a user-friendly development environment that makes it easy to get started with quantum programming. With QSDK developers also have access to new documnetation (QSDN), which will help them build robust and scalable applications. - - - 5 - QST - Positive - Quantum Software acquires a promising company - Quantum Software management has confirmed the purchase of a small software company. According to the company's management, the deal turned out to be very beneficial for both parties. The new software will soon be available on Quore OS operating systems and the company expects sales to increase in the near future. - - - 5 - QST - Positive - Quantum Software invests in Quantum Sky development - Quantum Software announced a major investment in the development of Quantum Sky, its cloud platform and infrastructure for creating innovative solutions in artificial intelligence, big data and internet of things. Quantum Sky aims to provide customers with access to the most advanced quantum computing resources and services, as well as to foster collaboration and innovation among researchers, developers and entrepreneurs. Quantum Software expects that Quantum Sky will boost its revenue and market share - - - 15 - QST - Negative - The Antimonopoly Commission accused Quantum Software of illegally maintaining its monopoly position - The Antimonopoly Commission announced that it has launched an investigation into Quantum Software. The commission claims that Quantum Software has abused its dominant position by engaging in unfair practices such as predatory pricing, exclusive contracts, and bundling products. The commission said that these practices have harmed consumers and competitors, and stifled innovation in the software market. The company said that it operates in a highly competitive and dynamic environment, and that its success is based on its superior products and services. - - - 10 - QST - Negative - Quantum Software reported a data breach - Some of the company’s servers were hacked by unknown attackers. The company is working with the police on this matter, but it is already known that their development of an unreleased operating system was stolen. The stolen data may contain sensitive information and secrets that could damage the company’s business. The company may also face legal action from its partners and customers who were affected by the breach. - - - 5 - QST - Negative - Users are unhappy with the latest Quore OS update - The latest update of Quore OS leads to numerous system breakdowns, and in some cases, loss of user data. Quantum Software has already apologized for the inconvenience and is working to remedy the situation. However, this event has caused many to consider alternative products, which could lead to a decrease in sales of Quantum Software. - - - 5 - QST - Negative - Quantum Software breaks partnership with driver manufacturer - Quantum Software management announced the termination of cooperation with one of the largest manufacturers of drivers for their systems. The reasons for this abrupt decision are not clear. The company said it is looking into alternative solutions to this problem. However, this may cause their operating systems to fall behind technically and reduce profits. - - - 5 - QST - Negative - Quantum Software faced mass layoffs - The company is facing massive layoffs. Employees say that before the release of the next major update, management began to set impossible tasks for them and give them the shortest possible time. The company's management has not yet commented on this, but this news will definitely not benefit the company's share prices. - - - 15 - EDSN - Positive - Edison Incorporated presents its new electric car - The company’s new electric cars with autopilot function went on sale in several countries. Edison Incorporated has managed to reduce the charging time of the car and increase its battery life by using innovative technology and materials. The first owners of electric cars are already leaving positive reviews and praising the performance and design of the car. The company expects to increase its sales and market share in the electric vehicle industry. - - - 10 - EDSN - Positive - Edison Incorporated enters the Asian market - The company has announced that it will start selling its electric vehicles in several Asian countries, including China, Japan, and India. The company said that it sees a huge potential for growth in these markets, as the demand for green and smart transportation is increasing. Edison Incorporated expects that this move will boost its sales and revenue, as well as its brand recognition and reputation. - - - 5 - EDSN - Positive - Edison Incorporated launches a successful advertising campaign - The company has launched a new advertising campaign to promote its electric vehicles and solar panels. The campaign features celebrities, influencers, and ordinary people who share their positive experiences with the company’s products and services. The campaign also highlights the environmental and economic benefits of switching to renewable energy sources. The campaign has received a lot of positive feedback and attention from the public and the media, and has increased the company’s popularity and customer loyalty. - - - 5 - EDSN - Positive - Edison Incorporated develops a more efficient electric engine - Edison Incorporated has developed a new electric engine that is more efficient and powerful than its previous models. The new engine uses less energy and produces less noise and emissions. The company said that the new engine will improve the performance and range of its electric vehicles, as well as reduce the maintenance costs and carbon footprint. The company plans to implement the new engine in its upcoming models and offer it as an upgrade option for existing customers. - - - 5 - EDSN - Positive - Edison Incorporated reduces the prices of its products - The company has announced that it will reduce the prices of its electric vehicles and solar panels by 10%. Edison Incorporated said that this decision is motivated by its desire to make its products more affordable and accessible to a wider range of customers. The company also said that it has achieved significant cost reductions thanks to its technological innovations and economies of scale. The price reduction is expected to increase the demand and sales of the company’s products, as well as its market share and competitiveness. - - - 15 - EDSN - Negative - Edison Incorporated is facing production difficulties - The company said it was having difficulty mining lithium, which is a key material for producing batteries for electric vehicles. The company blamed the shortage of lithium on environmental issues and political instability in some regions. Edison Incorporated assures that the difficulties are temporary and that it is looking for alternative sources of lithium. But we can already say that they harmed the company’s production and profits. - - - 10 - EDSN - Negative - Edison Incorporated recalls some of its electric vehicles - Edison Incorporated has announced that it will recall some of its electric vehicles due to a defect in the battery system that could cause overheating and fire. The company said that the recall affects a small percentage of its vehicles and that it will provide free repairs and replacements to the affected customers. The company apologized for the inconvenience and said that it is taking all the necessary measures to ensure the safety and quality of its products. However, this incident has damaged the company’s reputation and customer confidence. - - - 5 - EDSN - Negative - Edison Incorporated faces increased competition in the electric vehicle market - The company faces increased competition from other companies that are also producing and selling electric vehicles. Some of these competitors offer similar or better products at lower prices or with more features and options. The company said that it is confident in its products and services and that it will continue to innovate and improve its offerings. However, this may affect the company’s sales and market share, as customers may choose other alternatives. - - - 5 - EDSN - Negative - Customers criticize Edison Incorporated - The company has received some criticism from its customers who are unhappy with some aspects of its products and services. The customers have complained about the high prices, long delivery times, and poor customer service of the company. The company has responded to the criticism by acknowledging the issues and promising to improve its performance and quality. Edison Incorporated said that it values its customers’ feedback and that it will use it to enhance its products and services. The company hopes that this will restore its customer trust and satisfaction. - - - 5 - EDSN - Negative - Edison Incorporated reports problems with its autopilot system - The company has reported that some of its electric vehicles have experienced problems with their autopilot system. The system is supposed to assist the driver in steering, braking, and changing lanes, but some customers have reported that it has malfunctioned or failed to respond in some situations. Edison Incorporated said that it is investigating the cause of the problems and that it will issue a software update to fix them. The company also advised its customers to always pay attention and be ready to take over the control of the vehicle when using the autopilot system. The problems have raised some safety and reliability concerns among the customers and the regulators. - - - 15 - NTF - Positive - Netfilm announces new series - The company has confirmed the creation of its new series, which will be exclusive to its platform. The title and plot are still unknown, but the public already looks interested and curious. The company said that the new series will be a high-quality production with a talented cast and crew. The company hopes that the new series will attract more subscribers and viewers to its platform. - - - 10 - NTF - Positive - Netfilm wins awards for its original content - The company has won several awards for its original content, including movies and series. The awards recognize Netfilm’s creativity and excellence in producing and streaming high-quality content that appeals to a wide audience. The awards also boost Netfilm’s reputation and popularity in the online streaming industry. - - - 5 - NTF - Positive - Netfilm improves its video hosting service - Netfilm has announced that it has improved its video hosting service, which allows users to upload and stream their own videos on its platform. The company said that the improvement will enhance the quality, speed, and security of the video hosting service, as well as provide more options and features for users. The company said that the improvement will attract more users and creators to its platform, and increase its revenue and profit. - - - 5 - NTF - Positive - Netfilm offers a subscription discount - Netfilm has announced that it will offer a subscription discount for its customers who sign up for a year or more. The company said that the discount will make its service more affordable and accessible for its customers, as well as increase its customer loyalty and retention. The company said that the discount is part of its customer appreciation and promotion campaign. - - - 5 - NTF - Positive - Netfilm rewards its loyal customers - Netfilm has announced that it has rewarded its loyal customers with special offers and benefits. The company said that it has launched a loyalty program that allows its customers to earn points and redeem them for discounts, free trials, or exclusive content. The company also said that it has sent personalized recommendations and gifts to its customers, based on their preferences and interests. - - - 15 - NTF - Negative - Netfilm faced lawsuit - Netfilm sued by movie studios for streaming their content without permission. Netfilm denies the charges and says it has a fair use policy that allows it to stream content for educational and entertainment purposes. The lawsuit could affect the online streaming industry and set a precedent for future cases. The company may have to pay a large amount of money in damages or remove some content from its platform. - - - 10 - NTF - Negative - Netfilm delays new releases - Netfilm has announced that it will delay some of its new releases, due to production difficulties or quality issues. The company said that it wants to ensure that its new releases meet its high standards and expectations, and that it apologizes for any inconvenience caused to its customers. However, this decision has disappointed some of its customers who were eagerly waiting for the new releases, and has given an advantage to its competitors who have released their content on time. - - - 5 - NTF - Negative - Netfilm faces controversy over its content - Netfilm has faced controversy over some of its content, which has been accused of being offensive, inappropriate, or inaccurate. Some of its content has sparked backlash and criticism from various groups and individuals, who have demanded that Netfilm remove or apologize for the content. Some of its content has also been banned or censored in some countries or regions, due to legal or cultural reasons. This controversy has harmed Netfilm’s image and reputation, as well as caused some of its customers and partners to boycott or cancel its service. - - - 5 - NTF - Negative - Netfilm faces piracy threat - Netfilm has faced piracy threat, which has affected its revenue and profit. The company has discovered that some of its content has been illegally copied or distributed by unauthorized parties or platforms. The company has also found that some of its customers have shared their accounts or passwords with others, who have accessed its service without paying. The company said that it is taking measures to protect its intellectual property rights and to prevent piracy. However, this situation has reduced Netfilm’s income and market share, as well as damaged its exclusivity and value. - - - 5 - NTF - Negative - Netfilm faces employee strike - Netfilm has faced employee strike, which has disrupted its operations and productivity. The company’s employees have gone on strike to demand better working conditions, wages, and benefits. The company said that it is negotiating with the employees and their representatives, and that it hopes to reach a fair and reasonable agreement. However, this situation has affected Netfilm’s performance and output, as well as its relationship and trust with its employees. - - - 15 - CSC - Positive - COBRA Security Consulting signs a contract with the government - The company signed a contract with the government to ensure the security of state facilities such as military bases, power plants, airports, etc. COBRA operatives are already arriving at the facilities and setting up security measures. The exact amount of the contract was not disclosed, but it is already clear that the contract is beneficial to both parties. The contract will provide a stable income for the company and enhance the security of the state facilities. - - - 10 - CSC - Positive - The United Nations gives permission for COBRA Security Consulting to operate in new territories - The United Nations has granted permission for COBRA Security Consulting to operate in new territories that are under its supervision and protection. The permission allows the company to provide security services and solutions to various clients and sectors in these territories, such as humanitarian organizations, businesses, and governments. The company said that the permission is a sign of its credibility and reputation, as well as an opportunity to expand its scope and impact. - - - 5 - CSC - Positive - COBRA Security Consulting successfully completes the rescue operation - COBRA Security Consulting announced that it has successfully completed the rescue operation of a group of hostages held by a terrorist organization in a remote location. The operation involved a team of highly trained and experienced operatives who infiltrated the enemy camp and freed the hostages without any casualties. The hostages were then transported to a safe place and reunited with their families. The company said that the operation was a testament to its skills and dedication to saving lives. - - - 5 - CSC - Positive - COBRA Security Consulting unveils its new technology and equipment - COBRA Security Consulting unveils its new technology and equipment for its operatives. The new technology and equipment include advanced drones, sensors, weapons, and communication devices that enhance the capabilities and safety of its operatives. The company said that the new technology and equipment will give it an edge over its competitors and adversaries - - - 5 - CSC - Positive - COBRA Security Consulting secures a supply contract with government - COBRA Security Consulting revealed that it has provided security supplies to the government as part of a contract to equip its forces and agencies with the latest security equipment and technology. The contract will enhance the company’s revenue and reputation, as well as show its competence and dependability of its products and services. The company said that the contract is an acknowledgment of its innovation and excellence, and that it is pleased and honored to collaborate with the government. - - - 15 - CSC - Negative - COBRA Security Consulting is being criticized for their violent actions - COBRA Security Consulting has been criticized for its harsh actions in the Middle East on the territory of the facilities under its protection. The company’s management states that this is necessary to ensure security in the region and prevent terrorist attacks. However, some human rights organizations and media outlets accuse the company of using excessive force and violating international law. Government has already become interested in this case, and most likely the company will face punishment such as sanctions, fines, or termination of contracts. - - - 10 - CSC - Negative - COBRA Security Consulting brigades were captured - COBRA Security Consulting confirmed that some of its brigades were captured by a rebel group during a security operation. The brigades were part of a team that was providing security and escort to a convoy of humanitarian aid workers who were delivering supplies to a war-torn area. The rebel group ambushed the convoy and took the brigades as hostages. The company said that it is in contact with the rebel group and is negotiating for the release of the brigades. The company also said that it is doing everything in its power to ensure the safety and well-being of its brigades. - - - 5 - CSC - Negative - Fighter of COBRA Security Consulting was shot down - COBRA Security Consulting confirmed that one of its fighters was shot down by an unknown enemy during a security mission. The fighter was part of a team that was providing air support to a client who was under attack by a hostile force. The fighter was hit by a missile and crashed in a remote area. The company said that it is trying to locate and rescue the pilot, who is presumed to be alive. The company also said that it is investigating the identity and motive of the enemy who shot down the fighter. - - - 5 - CSC - Negative - COBRA Security Consulting vehicle involved in a deadly accident - A COBRA Security Consulting vehicle has been involved in a serious accident that resulted in several casualties, including civilians and company personnel. The accident happened during a convoy operation, and the cause of the accident is still under investigation. The company is offering support and compensation to the victims and their families, but it may face legal action and reputational damage from the incident. - - - 5 - CSC - Negative - COBRA Security Consulting staff arrested for illegal activity - 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's reputation and credibility, and it may face legal consequences if found guilty of any wrongdoing. - - - \ No newline at end of file diff --git a/Projects/Oligopoly/Event.cs b/Projects/Oligopoly/Event.cs index 8ce4ba3a..4e83931d 100644 --- a/Projects/Oligopoly/Event.cs +++ b/Projects/Oligopoly/Event.cs @@ -1,120 +1,12 @@ -using System.Xml; -using System.Xml.Serialization; +#nullable disable -namespace Oligopoly.Source -{ - [XmlRoot("Events")] - public class Event - { - // Create a class fields. - private int effect; - private string target; - private string type; - private string title; - private string content; - - [XmlElement("Effect")] - public int Effect - { - get - { - return effect; - } - set - { - if (value <= 0) - { - throw new InvalidOperationException("Effect cannot be less or equal to zero."); - } - else - { - effect = value; - } - } - } - - [XmlElement("Target")] - public string Target - { - get - { - return target; - } - set - { - if (string.IsNullOrEmpty(value)) - { - throw new InvalidOperationException("Target cannot be null or whitespace."); - } - else - { - target = value; - } - } - } +namespace Oligopoly; - [XmlElement("Type")] - public string Type - { - get - { - return type; - } - set - { - if (string.IsNullOrEmpty(value)) - { - throw new InvalidOperationException("Type cannot be null or whitespace."); - } - else if (value != "Positive" && value != "Negative") - { - throw new InvalidOperationException("Type cannot contain value other then Positive or Negative"); - } - else - { - type = value; - } - } - } - - [XmlElement("Title")] - public string Title - { - get - { - return title; - } - set - { - if (string.IsNullOrEmpty(value)) - { - throw new InvalidOperationException("Title cannot be null or whitespace."); - } - else - { - title = value; - } - } - } - - [XmlElement("Content")] - public string Content - { - get - { - return content; - } - set - { - if (string.IsNullOrEmpty(value)) - { - throw new InvalidOperationException("Content cannot be null or whitespace."); - } - else - { - content = value; - } - } - } - } -} \ No newline at end of file +public class Event +{ + public int Effect { get; set; } + public string Target { get; set; } + public string Type { get; set; } + public string Title { get; set; } + public string Content { get; set; } +} diff --git a/Projects/Oligopoly/Event.json b/Projects/Oligopoly/Event.json new file mode 100644 index 00000000..1722d7df --- /dev/null +++ b/Projects/Oligopoly/Event.json @@ -0,0 +1,352 @@ +[ + { + "Effect": 15, + "Target": "BNG", + "Type": "Positive", + "Title": "Bingoo announcing their new search engine", + "Content": "The company has announced its new search engine that will be more productive and user-friendly than the previous one. The search engine also uses artificial intelligence technology to improve search results and provide personalized recommendations to users. Experts predict that this will increase the value of the company\u2019s shares and attract more customers to its products and services." + }, + { + "Effect": 10, + "Target": "BNG", + "Type": "Positive", + "Title": "Bingoo announcing their new AI assistant", + "Content": "Bingoo has unveiled its latest innovation: Bingy. An AI assistant that can chat, search, and create content for users. Bingy is powered by advanced natural language processing and machine learning technologies that enable it to understand and communicate fluently in multiple languages. Bingy is available as an application that users can install on their computers or phones for easy and convenient access." + }, + { + "Effect": 5, + "Target": "BNG", + "Type": "Positive", + "Title": "Bingoo introduces new features and improvements for its web services", + "Content": "Bingoo has introduced a series of new features and improvements for its web services. The new features include voice search, image recognition, personalized recommendations, smart suggestions, faster loading times, better security and more. The updates apply to Bingoo\u0027s popular web services such as Bingoo Mail, Bingoo Cloud, Bingoo Maps, Bingoo News and others." + }, + { + "Effect": 5, + "Target": "BNG", + "Type": "Positive", + "Title": "Bingoo creates a special event to attract more web developers", + "Content": "The event, called Bingoo Webathon, is a 24-hour online marathon of web development challenges, tutorials, demos and prizes. Bingoo said that the event is designed to showcase its web services and web applications and to inspire and motivate web developers of all levels and backgrounds to join its community and platform. " + }, + { + "Effect": 5, + "Target": "BNG", + "Type": "Positive", + "Title": "Bingoo wins industry award for innovative web services", + "Content": "Bingoo has won an industry award for its innovative and user-friendly web services, including its search engine and web applications. The award recognizes Bingoo\u0027s commitment to providing the best possible user experiences and staying at the forefront of technology trends." + }, + { + "Effect": 15, + "Target": "BNG", + "Type": "Negative", + "Title": "Bingoo was accused of violating user privacy", + "Content": "The company was accused of stealing the personal data of its users and selling it to third parties without their consent. The case is currently under investigation by the authorities, but experts believe that this scandal will harm the company and its reputation. The company may face legal consequences and lose the trust of its users." + }, + { + "Effect": 10, + "Target": "BNG", + "Type": "Negative", + "Title": "Bingoo\u0027s servers experience a service outage", + "Content": "Bingoo\u0027s services have been down for several hours due to a technical issue. Users have been unable to access their accounts, send emails, or use other Bingoo services during this time. The company has released a statement apologizing for the inconvenience and stating that it is working to resolve the issue as soon as possible." + }, + { + "Effect": 5, + "Target": "BNG", + "Type": "Negative", + "Title": "Bingoo missed out on a lucrative acquisition deal", + "Content": "Bingoo was in talks to acquire a promising startup that could have helped the company expand its services and increase its market share. However, the company\u0027s management decided to abandon the deal at the last minute, citing concerns about the startup\u0027s financial health and market potential. This decision was criticized by shareholders and industry experts, who believe that Bingoo missed a valuable opportunity to grow its business and compete with its rivals." + }, + { + "Effect": 5, + "Target": "BNG", + "Type": "Negative", + "Title": "Bingoo criticized for excessive advertising in its products", + "Content": "Bingoo has been heavily criticized by its users for the excessive amount of ads present in its search engine. Many users have complained that the ads are intrusive and negatively affect their experience with the product. This has led to a decrease in user satisfaction and may ultimately lead to a decrease in sales." + }, + { + "Effect": 5, + "Target": "BNG", + "Type": "Negative", + "Title": "Bingoo terminates partnerships with phone manufacturers", + "Content": "Bingoo has announced that it will no longer be partnering with phone manufacturers to pre-install its search engine on their devices. This decision has been met with disappointment from phone manufacturers, as Bingoo\u0027s search engine is a popular choice among users. The move may lead to a decrease in Bingoo\u0027s market share and revenue, as users may choose other search engines instead." + }, + { + "Effect": 15, + "Target": "QST", + "Type": "Positive", + "Title": "Quantum Software announces new operating system", + "Content": "The company has introduced its new operating system from the Qore OS family at a presentation event. The company claims that the new operating system is more reliable and faster than the competitors\u2019 ones. The new operating system also has new features and functions that enhance the user experience. Experts expect the company\u2019s share price to rise and the new operating system to become popular among users." + }, + { + "Effect": 10, + "Target": "QST", + "Type": "Positive", + "Title": "Quantum Software announces update for Quantum Workflow", + "Content": "Quantum Software has just announced an exciting new update for its popular software package - Quantum Workflow. This new version is packed with innovative features and improvements that are sure to streamline your workflow and boost productivity. With its user-friendly interface and powerful capabilities, Quantum Workflow has already become a favorite among professionals in a variety of industries." + }, + { + "Effect": 5, + "Target": "QST", + "Type": "Positive", + "Title": "Quantum Software presents its new development kit", + "Content": "The company has inoduced its new update for software development kit (QSDK). The new QSDK includes a powerful quantum simulator, a comprehensive set of libraries and frameworks, and a user-friendly development environment that makes it easy to get started with quantum programming. With QSDK developers also have access to new documnetation (QSDN), which will help them build robust and scalable applications." + }, + { + "Effect": 5, + "Target": "QST", + "Type": "Positive", + "Title": "Quantum Software acquires a promising company", + "Content": "Quantum Software management has confirmed the purchase of a small software company. According to the company\u0027s management, the deal turned out to be very beneficial for both parties. The new software will soon be available on Quore OS operating systems and the company expects sales to increase in the near future." + }, + { + "Effect": 5, + "Target": "QST", + "Type": "Positive", + "Title": "Quantum Software invests in Quantum Sky development", + "Content": "Quantum Software announced a major investment in the development of Quantum Sky, its cloud platform and infrastructure for creating innovative solutions in artificial intelligence, big data and internet of things. Quantum Sky aims to provide customers with access to the most advanced quantum computing resources and services, as well as to foster collaboration and innovation among researchers, developers and entrepreneurs. Quantum Software expects that Quantum Sky will boost its revenue and market share" + }, + { + "Effect": 15, + "Target": "QST", + "Type": "Negative", + "Title": "The Antimonopoly Commission accused Quantum Software of illegally maintaining its monopoly position", + "Content": "The Antimonopoly Commission announced that it has launched an investigation into Quantum Software. The commission claims that Quantum Software has abused its dominant position by engaging in unfair practices such as predatory pricing, exclusive contracts, and bundling products. The commission said that these practices have harmed consumers and competitors, and stifled innovation in the software market. The company said that it operates in a highly competitive and dynamic environment, and that its success is based on its superior products and services." + }, + { + "Effect": 10, + "Target": "QST", + "Type": "Negative", + "Title": "Quantum Software reported a data breach", + "Content": "Some of the company\u2019s servers were hacked by unknown attackers. The company is working with the police on this matter, but it is already known that their development of an unreleased operating system was stolen. The stolen data may contain sensitive information and secrets that could damage the company\u2019s business. The company may also face legal action from its partners and customers who were affected by the breach." + }, + { + "Effect": 5, + "Target": "QST", + "Type": "Negative", + "Title": "Users are unhappy with the latest Quore OS update", + "Content": "The latest update of Quore OS leads to numerous system breakdowns, and in some cases, loss of user data. Quantum Software has already apologized for the inconvenience and is working to remedy the situation. However, this event has caused many to consider alternative products, which could lead to a decrease in sales of Quantum Software." + }, + { + "Effect": 5, + "Target": "QST", + "Type": "Negative", + "Title": "Quantum Software breaks partnership with driver manufacturer", + "Content": "Quantum Software management announced the termination of cooperation with one of the largest manufacturers of drivers for their systems. The reasons for this abrupt decision are not clear. The company said it is looking into alternative solutions to this problem. However, this may cause their operating systems to fall behind technically and reduce profits." + }, + { + "Effect": 5, + "Target": "QST", + "Type": "Negative", + "Title": "Quantum Software faced mass layoffs", + "Content": "The company is facing massive layoffs. Employees say that before the release of the next major update, management began to set impossible tasks for them and give them the shortest possible time. The company\u0027s management has not yet commented on this, but this news will definitely not benefit the company\u0027s share prices." + }, + { + "Effect": 15, + "Target": "EDSN", + "Type": "Positive", + "Title": "Edison Incorporated presents its new electric car", + "Content": "The company\u2019s new electric cars with autopilot function went on sale in several countries. Edison Incorporated has managed to reduce the charging time of the car and increase its battery life by using innovative technology and materials. The first owners of electric cars are already leaving positive reviews and praising the performance and design of the car. The company expects to increase its sales and market share in the electric vehicle industry." + }, + { + "Effect": 10, + "Target": "EDSN", + "Type": "Positive", + "Title": "Edison Incorporated enters the Asian market", + "Content": "The company has announced that it will start selling its electric vehicles in several Asian countries, including China, Japan, and India. The company said that it sees a huge potential for growth in these markets, as the demand for green and smart transportation is increasing. Edison Incorporated expects that this move will boost its sales and revenue, as well as its brand recognition and reputation." + }, + { + "Effect": 5, + "Target": "EDSN", + "Type": "Positive", + "Title": "Edison Incorporated launches a successful advertising campaign", + "Content": "The company has launched a new advertising campaign to promote its electric vehicles and solar panels. The campaign features celebrities, influencers, and ordinary people who share their positive experiences with the company\u2019s products and services. The campaign also highlights the environmental and economic benefits of switching to renewable energy sources. The campaign has received a lot of positive feedback and attention from the public and the media, and has increased the company\u2019s popularity and customer loyalty." + }, + { + "Effect": 5, + "Target": "EDSN", + "Type": "Positive", + "Title": "Edison Incorporated develops a more efficient electric engine", + "Content": "Edison Incorporated has developed a new electric engine that is more efficient and powerful than its previous models. The new engine uses less energy and produces less noise and emissions. The company said that the new engine will improve the performance and range of its electric vehicles, as well as reduce the maintenance costs and carbon footprint. The company plans to implement the new engine in its upcoming models and offer it as an upgrade option for existing customers. " + }, + { + "Effect": 5, + "Target": "EDSN", + "Type": "Positive", + "Title": "Edison Incorporated reduces the prices of its products", + "Content": "The company has announced that it will reduce the prices of its electric vehicles and solar panels by 10%. Edison Incorporated said that this decision is motivated by its desire to make its products more affordable and accessible to a wider range of customers. The company also said that it has achieved significant cost reductions thanks to its technological innovations and economies of scale. The price reduction is expected to increase the demand and sales of the company\u2019s products, as well as its market share and competitiveness." + }, + { + "Effect": 15, + "Target": "EDSN", + "Type": "Negative", + "Title": "Edison Incorporated is facing production difficulties", + "Content": "The company said it was having difficulty mining lithium, which is a key material for producing batteries for electric vehicles. The company blamed the shortage of lithium on environmental issues and political instability in some regions. Edison Incorporated assures that the difficulties are temporary and that it is looking for alternative sources of lithium. But we can already say that they harmed the company\u2019s production and profits." + }, + { + "Effect": 10, + "Target": "EDSN", + "Type": "Negative", + "Title": "Edison Incorporated recalls some of its electric vehicles ", + "Content": "Edison Incorporated has announced that it will recall some of its electric vehicles due to a defect in the battery system that could cause overheating and fire. The company said that the recall affects a small percentage of its vehicles and that it will provide free repairs and replacements to the affected customers. The company apologized for the inconvenience and said that it is taking all the necessary measures to ensure the safety and quality of its products. However, this incident has damaged the company\u2019s reputation and customer confidence." + }, + { + "Effect": 5, + "Target": "EDSN", + "Type": "Negative", + "Title": "Edison Incorporated faces increased competition in the electric vehicle market", + "Content": "The company faces increased competition from other companies that are also producing and selling electric vehicles. Some of these competitors offer similar or better products at lower prices or with more features and options. The company said that it is confident in its products and services and that it will continue to innovate and improve its offerings. However, this may affect the company\u2019s sales and market share, as customers may choose other alternatives. " + }, + { + "Effect": 5, + "Target": "EDSN", + "Type": "Negative", + "Title": "Customers criticize Edison Incorporated", + "Content": "The company has received some criticism from its customers who are unhappy with some aspects of its products and services. The customers have complained about the high prices, long delivery times, and poor customer service of the company. The company has responded to the criticism by acknowledging the issues and promising to improve its performance and quality. Edison Incorporated said that it values its customers\u2019 feedback and that it will use it to enhance its products and services. The company hopes that this will restore its customer trust and satisfaction." + }, + { + "Effect": 5, + "Target": "EDSN", + "Type": "Negative", + "Title": "Edison Incorporated reports problems with its autopilot system", + "Content": "The company has reported that some of its electric vehicles have experienced problems with their autopilot system. The system is supposed to assist the driver in steering, braking, and changing lanes, but some customers have reported that it has malfunctioned or failed to respond in some situations. Edison Incorporated said that it is investigating the cause of the problems and that it will issue a software update to fix them. The company also advised its customers to always pay attention and be ready to take over the control of the vehicle when using the autopilot system. The problems have raised some safety and reliability concerns among the customers and the regulators." + }, + { + "Effect": 15, + "Target": "NTF", + "Type": "Positive", + "Title": "Netfilm announces new series", + "Content": "The company has confirmed the creation of its new series, which will be exclusive to its platform. The title and plot are still unknown, but the public already looks interested and curious. The company said that the new series will be a high-quality production with a talented cast and crew. The company hopes that the new series will attract more subscribers and viewers to its platform." + }, + { + "Effect": 10, + "Target": "NTF", + "Type": "Positive", + "Title": "Netfilm wins awards for its original content", + "Content": "The company has won several awards for its original content, including movies and series. The awards recognize Netfilm\u2019s creativity and excellence in producing and streaming high-quality content that appeals to a wide audience. The awards also boost Netfilm\u2019s reputation and popularity in the online streaming industry." + }, + { + "Effect": 5, + "Target": "NTF", + "Type": "Positive", + "Title": "Netfilm improves its video hosting service", + "Content": "Netfilm has announced that it has improved its video hosting service, which allows users to upload and stream their own videos on its platform. The company said that the improvement will enhance the quality, speed, and security of the video hosting service, as well as provide more options and features for users. The company said that the improvement will attract more users and creators to its platform, and increase its revenue and profit." + }, + { + "Effect": 5, + "Target": "NTF", + "Type": "Positive", + "Title": "Netfilm offers a subscription discount", + "Content": "Netfilm has announced that it will offer a subscription discount for its customers who sign up for a year or more. The company said that the discount will make its service more affordable and accessible for its customers, as well as increase its customer loyalty and retention. The company said that the discount is part of its customer appreciation and promotion campaign." + }, + { + "Effect": 5, + "Target": "NTF", + "Type": "Positive", + "Title": "Netfilm rewards its loyal customers", + "Content": "Netfilm has announced that it has rewarded its loyal customers with special offers and benefits. The company said that it has launched a loyalty program that allows its customers to earn points and redeem them for discounts, free trials, or exclusive content. The company also said that it has sent personalized recommendations and gifts to its customers, based on their preferences and interests." + }, + { + "Effect": 15, + "Target": "NTF", + "Type": "Negative", + "Title": "Netfilm faced lawsuit", + "Content": "Netfilm sued by movie studios for streaming their content without permission. Netfilm denies the charges and says it has a fair use policy that allows it to stream content for educational and entertainment purposes. The lawsuit could affect the online streaming industry and set a precedent for future cases. The company may have to pay a large amount of money in damages or remove some content from its platform." + }, + { + "Effect": 10, + "Target": "NTF", + "Type": "Negative", + "Title": "Netfilm delays new releases", + "Content": "Netfilm has announced that it will delay some of its new releases, due to production difficulties or quality issues. The company said that it wants to ensure that its new releases meet its high standards and expectations, and that it apologizes for any inconvenience caused to its customers. However, this decision has disappointed some of its customers who were eagerly waiting for the new releases, and has given an advantage to its competitors who have released their content on time." + }, + { + "Effect": 5, + "Target": "NTF", + "Type": "Negative", + "Title": "Netfilm faces controversy over its content", + "Content": "Netfilm has faced controversy over some of its content, which has been accused of being offensive, inappropriate, or inaccurate. Some of its content has sparked backlash and criticism from various groups and individuals, who have demanded that Netfilm remove or apologize for the content. Some of its content has also been banned or censored in some countries or regions, due to legal or cultural reasons. This controversy has harmed Netfilm\u2019s image and reputation, as well as caused some of its customers and partners to boycott or cancel its service." + }, + { + "Effect": 5, + "Target": "NTF", + "Type": "Negative", + "Title": "Netfilm faces piracy threat", + "Content": "Netfilm has faced piracy threat, which has affected its revenue and profit. The company has discovered that some of its content has been illegally copied or distributed by unauthorized parties or platforms. The company has also found that some of its customers have shared their accounts or passwords with others, who have accessed its service without paying. The company said that it is taking measures to protect its intellectual property rights and to prevent piracy. However, this situation has reduced Netfilm\u2019s income and market share, as well as damaged its exclusivity and value." + }, + { + "Effect": 5, + "Target": "NTF", + "Type": "Negative", + "Title": "Netfilm faces employee strike", + "Content": "Netfilm has faced employee strike, which has disrupted its operations and productivity. The company\u2019s employees have gone on strike to demand better working conditions, wages, and benefits. The company said that it is negotiating with the employees and their representatives, and that it hopes to reach a fair and reasonable agreement. However, this situation has affected Netfilm\u2019s performance and output, as well as its relationship and trust with its employees." + }, + { + "Effect": 15, + "Target": "CSC", + "Type": "Positive", + "Title": "COBRA Security Consulting signs a contract with the government", + "Content": "The company signed a contract with the government to ensure the security of state facilities such as military bases, power plants, airports, etc. COBRA operatives are already arriving at the facilities and setting up security measures. The exact amount of the contract was not disclosed, but it is already clear that the contract is beneficial to both parties. The contract will provide a stable income for the company and enhance the security of the state facilities." + }, + { + "Effect": 10, + "Target": "CSC", + "Type": "Positive", + "Title": "The United Nations gives permission for COBRA Security Consulting to operate in new territories", + "Content": "The United Nations has granted permission for COBRA Security Consulting to operate in new territories that are under its supervision and protection. The permission allows the company to provide security services and solutions to various clients and sectors in these territories, such as humanitarian organizations, businesses, and governments. The company said that the permission is a sign of its credibility and reputation, as well as an opportunity to expand its scope and impact." + }, + { + "Effect": 5, + "Target": "CSC", + "Type": "Positive", + "Title": "COBRA Security Consulting successfully completes the rescue operation", + "Content": "COBRA Security Consulting announced that it has successfully completed the rescue operation of a group of hostages held by a terrorist organization in a remote location. The operation involved a team of highly trained and experienced operatives who infiltrated the enemy camp and freed the hostages without any casualties. The hostages were then transported to a safe place and reunited with their families. The company said that the operation was a testament to its skills and dedication to saving lives." + }, + { + "Effect": 5, + "Target": "CSC", + "Type": "Positive", + "Title": "COBRA Security Consulting unveils its new technology and equipment", + "Content": "COBRA Security Consulting unveils its new technology and equipment for its operatives. The new technology and equipment include advanced drones, sensors, weapons, and communication devices that enhance the capabilities and safety of its operatives. The company said that the new technology and equipment will give it an edge over its competitors and adversaries" + }, + { + "Effect": 5, + "Target": "CSC", + "Type": "Positive", + "Title": "COBRA Security Consulting secures a supply contract with government", + "Content": "COBRA Security Consulting revealed that it has provided security supplies to the government as part of a contract to equip its forces and agencies with the latest security equipment and technology. The contract will enhance the company\u2019s revenue and reputation, as well as show its competence and dependability of its products and services. The company said that the contract is an acknowledgment of its innovation and excellence, and that it is pleased and honored to collaborate with the government." + }, + { + "Effect": 15, + "Target": "CSC", + "Type": "Negative", + "Title": "COBRA Security Consulting is being criticized for their violent actions", + "Content": "COBRA Security Consulting has been criticized for its harsh actions in the Middle East on the territory of the facilities under its protection. The company\u2019s management states that this is necessary to ensure security in the region and prevent terrorist attacks. However, some human rights organizations and media outlets accuse the company of using excessive force and violating international law. Government has already become interested in this case, and most likely the company will face punishment such as sanctions, fines, or termination of contracts." + }, + { + "Effect": 10, + "Target": "CSC", + "Type": "Negative", + "Title": "COBRA Security Consulting brigades were captured", + "Content": "COBRA Security Consulting confirmed that some of its brigades were captured by a rebel group during a security operation. The brigades were part of a team that was providing security and escort to a convoy of humanitarian aid workers who were delivering supplies to a war-torn area. The rebel group ambushed the convoy and took the brigades as hostages. The company said that it is in contact with the rebel group and is negotiating for the release of the brigades. The company also said that it is doing everything in its power to ensure the safety and well-being of its brigades." + }, + { + "Effect": 5, + "Target": "CSC", + "Type": "Negative", + "Title": "Fighter of COBRA Security Consulting was shot down", + "Content": "COBRA Security Consulting confirmed that one of its fighters was shot down by an unknown enemy during a security mission. The fighter was part of a team that was providing air support to a client who was under attack by a hostile force. The fighter was hit by a missile and crashed in a remote area. The company said that it is trying to locate and rescue the pilot, who is presumed to be alive. The company also said that it is investigating the identity and motive of the enemy who shot down the fighter." + }, + { + "Effect": 5, + "Target": "CSC", + "Type": "Negative", + "Title": "COBRA Security Consulting vehicle involved in a deadly accident", + "Content": "A COBRA Security Consulting vehicle has been involved in a serious accident that resulted in several casualties, including civilians and company personnel. The accident happened during a convoy operation, and the cause of the accident is still under investigation. The company is offering support and compensation to the victims and their families, but it may face legal action and reputational damage from the incident." + }, + { + "Effect": 5, + "Target": "CSC", + "Type": "Negative", + "Title": "COBRA Security Consulting staff arrested for illegal activity", + "Content": "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." + } +] \ No newline at end of file diff --git a/Projects/Oligopoly/GameMenu.cs b/Projects/Oligopoly/GameMenu.cs index 9c581c9a..adee201c 100644 --- a/Projects/Oligopoly/GameMenu.cs +++ b/Projects/Oligopoly/GameMenu.cs @@ -1,227 +1,223 @@ -namespace Oligopoly.Source +namespace Oligopoly; + +public class GameMenu : Menu { - public class GameMenu : Menu - { - // Create a class fields. - private int CurrentEvent; - private double Money; - private Data Data; - - /// - /// Initializes a new instance of the GameMenu class with given parameters. - /// - /// The prompt to display above the menu. - /// The options to display in the menu. - /// The text output delay. Have to be a positive integer or zero. - /// The integer that represents current event. - /// The Data class object, which contains all companies and events. - public GameMenu(string prompt, string[] options, int outputDelay, int currentEvent, double money, Data data) - : base(prompt, options, outputDelay) - { - CurrentEvent = currentEvent; - Money = money; - Data = data; - } - - /// - /// Displays menu to the console and redraws it when user select other option. - /// - protected override void DisplayMenu() - { - // Display amount of money. - Console.WriteLine(string.Format($"You have: {Math.Round(Money, 2)}$\n", -50)); - - // Display current event. - Console.WriteLine($"{Data.gameEvents[CurrentEvent].Title}"); - Console.WriteLine($"\n{Data.gameEvents[CurrentEvent].Content}\n"); - - // Display companies. - Console.Write("╔"); - for (int i = 0; i < 120 - 2; i++) - { - Console.Write("═"); - } - Console.WriteLine("╗"); - - Console.WriteLine(string.Format($"{"║ Company",-52} ║ {"Ticker",8} ║ {"Industry",10} ║ {"Share Price",19} ║ {"You Have",17} ║")); - - Console.Write("╚"); - for (int i = 0; i < 120 - 2; i++) - { - Console.Write("═"); - } - Console.WriteLine("╝"); - - Console.Write("╔"); - for (int i = 0; i < 120 - 2; i++) - { - Console.Write("═"); - } - Console.WriteLine("╗"); - - foreach (var company in Data.gameCompanies) - { - Console.WriteLine(string.Format($"║ {company.Name,-50} ║ {company.Ticker,8} ║ {company.Industry,10} ║ {company.SharePrice,19} ║ {company.ShareAmount,17} ║")); - } - - Console.Write("╚"); - for (int i = 0; i < 120 - 2; i++) - { - Console.Write("═"); - } - Console.WriteLine("╝"); - - // Display the prompt above the menu. - foreach (char symbol in Prompt) - { - Thread.Sleep(OutputDelay); - Console.Write(symbol); - } - - // Display all options inside the menu and redraw it when user select other option. - for (int i = 0; i < Options.Length; i++) - { - string currentOption = Options[i]; - string prefix; - - if (i == SelectedIndex) - { - prefix = "*"; - Console.ForegroundColor = ConsoleColor.Black; - Console.BackgroundColor = ConsoleColor.White; - } - else - { - prefix = " "; - Console.ForegroundColor = ConsoleColor.White; - Console.BackgroundColor = ConsoleColor.Black; - } - - Console.WriteLine($"[{prefix}] {currentOption}"); - } - - Console.ResetColor(); - } - - /// - /// Runs the menu. - /// - /// An integer that represents the selected option. - public override int RunMenu() - { - // Set output delay to 0. - // This is necessary so that the menu does not draw with a delay when updating the console. - OutputDelay = 0; - - // Create variable, that contains key that was pressed. - ConsoleKey keyPressed; - - do - { - // Redraw the menu. - Console.Clear(); - DisplayMenu(); - - //Read the user's input. - ConsoleKeyInfo keyInfo = Console.ReadKey(); - - // Get the key that was pressed. - keyPressed = keyInfo.Key; - - // Move the selection up or down, based on the pressed key. - if (keyPressed == ConsoleKey.UpArrow) - { - SelectedIndex--; - - // Wrap around if user is out of range. - if (SelectedIndex == -1) - { - SelectedIndex = Options.Length - 1; - } - } - else if (keyPressed == ConsoleKey.DownArrow) - { - SelectedIndex++; - - // Wrap around if user is out of range. - if (SelectedIndex == Options.Length) - { - SelectedIndex = 0; - } - } - } while (keyPressed != ConsoleKey.Enter); - - // Return the selected option. - return SelectedIndex; - } - - /// - /// Runs the amount menu. - /// - /// An integer, that represents the amount of shares. - public int RunAmountMenu() - { - // Set output delay to 0. - // This is necessary so that the menu does not draw with a delay when updating the console. - OutputDelay = 0; - - // Create variable, that contains key that was pressed. - ConsoleKey keyPressed; - - int amount = 0; - - do - { - // Redraw the menu. - Console.Clear(); - DisplayMenu(); - - // Display current amount of shares. - Console.WriteLine($"Current amount: {amount}"); - - //Read the user's input. - ConsoleKeyInfo keyInfo = Console.ReadKey(); - - // Get the key that was pressed. - keyPressed = keyInfo.Key; - - // Move the selection up or down, based on the pressed key. - if (keyPressed == ConsoleKey.UpArrow) - { - SelectedIndex--; - - // Wrap around if user is out of range. - if (SelectedIndex == -1) - { - SelectedIndex = Options.Length - 1; - } - } - else if (keyPressed == ConsoleKey.DownArrow) - { - SelectedIndex++; - - // Wrap around if user is out of range. - if (SelectedIndex == Options.Length) - { - SelectedIndex = 0; - } - } - - if (keyPressed == ConsoleKey.Enter && SelectedIndex == 0) - { - amount++; - } - else if (keyPressed == ConsoleKey.Enter && SelectedIndex == 1) - { - if (amount > 0) - { - amount--; - } - } - } while (!(keyPressed == ConsoleKey.Enter && SelectedIndex == 2)); - - // Return the amount of shares. - return amount; - } - } + private int CurrentEvent; + private double Money; + + /// + /// Initializes a new instance of the GameMenu class with given parameters. + /// + /// The prompt to display above the menu. + /// The options to display in the menu. + /// The text output delay. Have to be a positive integer or zero. + /// The integer that represents current event. + /// The Data class object, which contains all companies and events. + public GameMenu(string prompt, string[] options, int outputDelay, int currentEvent, double money) + : base(prompt, options, outputDelay) + { + CurrentEvent = currentEvent; + Money = money; + } + + /// + /// Displays menu to the console and redraws it when user select other option. + /// + protected override void DisplayMenu() + { + // Display amount of money. + Console.WriteLine(string.Format($"You have: {Math.Round(Money, 2)}$\n", -50)); + + // Display current event. + Console.WriteLine($"{Program.Events[CurrentEvent].Title}"); + Console.WriteLine($"\n{Program.Events[CurrentEvent].Content}\n"); + + // Display companies. + Console.Write("╔"); + for (int i = 0; i < 120 - 2; i++) + { + Console.Write("═"); + } + Console.WriteLine("╗"); + + Console.WriteLine(string.Format($"{"║ Company",-52} ║ {"Ticker",8} ║ {"Industry",10} ║ {"Share Price",19} ║ {"You Have",17} ║")); + + Console.Write("╚"); + for (int i = 0; i < 120 - 2; i++) + { + Console.Write("═"); + } + Console.WriteLine("╝"); + + Console.Write("╔"); + for (int i = 0; i < 120 - 2; i++) + { + Console.Write("═"); + } + Console.WriteLine("╗"); + + foreach (Company company in Program.Companies) + { + Console.WriteLine(string.Format($"║ {company.Name,-50} ║ {company.Ticker,8} ║ {company.Industry,10} ║ {company.SharePrice,19} ║ {company.ShareAmount,17} ║")); + } + + Console.Write("╚"); + for (int i = 0; i < 120 - 2; i++) + { + Console.Write("═"); + } + Console.WriteLine("╝"); + + // Display the prompt above the menu. + foreach (char symbol in Prompt) + { + Thread.Sleep(OutputDelay); + Console.Write(symbol); + } + + // Display all options inside the menu and redraw it when user select other option. + for (int i = 0; i < Options.Length; i++) + { + string currentOption = Options[i]; + string prefix; + + if (i == SelectedIndex) + { + prefix = "*"; + Console.ForegroundColor = ConsoleColor.Black; + Console.BackgroundColor = ConsoleColor.White; + } + else + { + prefix = " "; + Console.ForegroundColor = ConsoleColor.White; + Console.BackgroundColor = ConsoleColor.Black; + } + + Console.WriteLine($"[{prefix}] {currentOption}"); + } + + Console.ResetColor(); + } + + /// + /// Runs the menu. + /// + /// An integer that represents the selected option. + public override int RunMenu() + { + // Set output delay to 0. + // This is necessary so that the menu does not draw with a delay when updating the console. + OutputDelay = 0; + + // Create variable, that contains key that was pressed. + ConsoleKey keyPressed; + + do + { + // Redraw the menu. + Console.Clear(); + DisplayMenu(); + + //Read the user's input. + ConsoleKeyInfo keyInfo = Console.ReadKey(); + + // Get the key that was pressed. + keyPressed = keyInfo.Key; + + // Move the selection up or down, based on the pressed key. + if (keyPressed == ConsoleKey.UpArrow) + { + SelectedIndex--; + + // Wrap around if user is out of range. + if (SelectedIndex == -1) + { + SelectedIndex = Options.Length - 1; + } + } + else if (keyPressed == ConsoleKey.DownArrow) + { + SelectedIndex++; + + // Wrap around if user is out of range. + if (SelectedIndex == Options.Length) + { + SelectedIndex = 0; + } + } + } while (keyPressed != ConsoleKey.Enter); + + // Return the selected option. + return SelectedIndex; + } + + /// + /// Runs the amount menu. + /// + /// An integer, that represents the amount of shares. + public int RunAmountMenu() + { + // Set output delay to 0. + // This is necessary so that the menu does not draw with a delay when updating the console. + OutputDelay = 0; + + // Create variable, that contains key that was pressed. + ConsoleKey keyPressed; + + int amount = 0; + + do + { + // Redraw the menu. + Console.Clear(); + DisplayMenu(); + + // Display current amount of shares. + Console.WriteLine($"Current amount: {amount}"); + + //Read the user's input. + ConsoleKeyInfo keyInfo = Console.ReadKey(); + + // Get the key that was pressed. + keyPressed = keyInfo.Key; + + // Move the selection up or down, based on the pressed key. + if (keyPressed == ConsoleKey.UpArrow) + { + SelectedIndex--; + + // Wrap around if user is out of range. + if (SelectedIndex == -1) + { + SelectedIndex = Options.Length - 1; + } + } + else if (keyPressed == ConsoleKey.DownArrow) + { + SelectedIndex++; + + // Wrap around if user is out of range. + if (SelectedIndex == Options.Length) + { + SelectedIndex = 0; + } + } + + if (keyPressed == ConsoleKey.Enter && SelectedIndex == 0) + { + amount++; + } + else if (keyPressed == ConsoleKey.Enter && SelectedIndex == 1) + { + if (amount > 0) + { + amount--; + } + } + } while (!(keyPressed == ConsoleKey.Enter && SelectedIndex == 2)); + + // Return the amount of shares. + return amount; + } } \ No newline at end of file diff --git a/Projects/Oligopoly/Menu.cs b/Projects/Oligopoly/Menu.cs index a9c99b15..558dc375 100644 --- a/Projects/Oligopoly/Menu.cs +++ b/Projects/Oligopoly/Menu.cs @@ -1,115 +1,114 @@ -namespace Oligopoly.Source +namespace Oligopoly; + +public class Menu { - public class Menu - { - // Create a class fields. - protected int SelectedIndex; - protected int OutputDelay; - protected string Prompt; - protected string[] Options; - - /// - /// Initializes a new instance of the Menu class with given prompt, options and output delay. - /// - /// The prompt to display above the menu. - /// The options to display in the menu. - /// The text output delay. Have to be a positive integer or zero! - public Menu(string prompt, string[] options, int outputDelay) - { - Prompt = prompt; - Options = options; - OutputDelay = outputDelay; - SelectedIndex = 0; - } - - /// - /// Displays menu to the console and redraws it when user select other option. - /// - protected virtual void DisplayMenu() - { - // Display the prompt above the menu. - foreach (char symbol in Prompt) - { - Thread.Sleep(OutputDelay); - Console.Write(symbol); - } - - // Display all options inside the menu and redraw it when user select other option. - for (int i = 0; i < Options.Length; i++) - { - string currentOption = Options[i]; - string prefix; - - if (i == SelectedIndex) - { - prefix = "*"; - Console.ForegroundColor = ConsoleColor.Black; - Console.BackgroundColor = ConsoleColor.White; - } - else - { - prefix = " "; - Console.ForegroundColor = ConsoleColor.White; - Console.BackgroundColor = ConsoleColor.Black; - } - - Console.WriteLine($"[{prefix}] {currentOption}"); - } - - // Reset console colors. - Console.ResetColor(); - } - - /// - /// Runs the menu. - /// - /// An integer that represents the selected option. - public virtual int RunMenu() - { - // Set output delay to 0. - // This is necessary so that the menu does not draw with a delay when updating the console. - OutputDelay = 0; - - // Create variable, that contains key that was pressed. - ConsoleKey keyPressed; - - do - { - // Redraw the menu. - Console.Clear(); - DisplayMenu(); - - //Read the user's input. - ConsoleKeyInfo keyInfo = Console.ReadKey(); - - // Get the key that was pressed. - keyPressed = keyInfo.Key; - - // Move the selection up or down, based on the pressed key. - if (keyPressed == ConsoleKey.UpArrow) - { - SelectedIndex--; - - // Wrap around if user is out of range. - if (SelectedIndex == -1) - { - SelectedIndex = Options.Length - 1; - } - } - else if (keyPressed == ConsoleKey.DownArrow) - { - SelectedIndex++; - - // Wrap around if user is out of range. - if (SelectedIndex == Options.Length) - { - SelectedIndex = 0; - } - } - } while (keyPressed != ConsoleKey.Enter); - - // Return the selected option. - return SelectedIndex; - } - } + // Create a class fields. + protected int SelectedIndex; + protected int OutputDelay; + protected string Prompt; + protected string[] Options; + + /// + /// Initializes a new instance of the Menu class with given prompt, options and output delay. + /// + /// The prompt to display above the menu. + /// The options to display in the menu. + /// The text output delay. Have to be a positive integer or zero! + public Menu(string prompt, string[] options, int outputDelay) + { + Prompt = prompt; + Options = options; + OutputDelay = outputDelay; + SelectedIndex = 0; + } + + /// + /// Displays menu to the console and redraws it when user select other option. + /// + protected virtual void DisplayMenu() + { + // Display the prompt above the menu. + foreach (char symbol in Prompt) + { + Thread.Sleep(OutputDelay); + Console.Write(symbol); + } + + // Display all options inside the menu and redraw it when user select other option. + for (int i = 0; i < Options.Length; i++) + { + string currentOption = Options[i]; + string prefix; + + if (i == SelectedIndex) + { + prefix = "*"; + Console.ForegroundColor = ConsoleColor.Black; + Console.BackgroundColor = ConsoleColor.White; + } + else + { + prefix = " "; + Console.ForegroundColor = ConsoleColor.White; + Console.BackgroundColor = ConsoleColor.Black; + } + + Console.WriteLine($"[{prefix}] {currentOption}"); + } + + // Reset console colors. + Console.ResetColor(); + } + + /// + /// Runs the menu. + /// + /// An integer that represents the selected option. + public virtual int RunMenu() + { + // Set output delay to 0. + // This is necessary so that the menu does not draw with a delay when updating the console. + OutputDelay = 0; + + // Create variable, that contains key that was pressed. + ConsoleKey keyPressed; + + do + { + // Redraw the menu. + Console.Clear(); + DisplayMenu(); + + //Read the user's input. + ConsoleKeyInfo keyInfo = Console.ReadKey(); + + // Get the key that was pressed. + keyPressed = keyInfo.Key; + + // Move the selection up or down, based on the pressed key. + if (keyPressed == ConsoleKey.UpArrow) + { + SelectedIndex--; + + // Wrap around if user is out of range. + if (SelectedIndex == -1) + { + SelectedIndex = Options.Length - 1; + } + } + else if (keyPressed == ConsoleKey.DownArrow) + { + SelectedIndex++; + + // Wrap around if user is out of range. + if (SelectedIndex == Options.Length) + { + SelectedIndex = 0; + } + } + } while (keyPressed != ConsoleKey.Enter); + + // Return the selected option. + return SelectedIndex; + } } \ No newline at end of file diff --git a/Projects/Oligopoly/Oligopoly.csproj b/Projects/Oligopoly/Oligopoly.csproj index d011dcfd..45e819ff 100644 --- a/Projects/Oligopoly/Oligopoly.csproj +++ b/Projects/Oligopoly/Oligopoly.csproj @@ -3,11 +3,14 @@ Exe net6.0 enable - disable + enable - - Always - + + + + + + diff --git a/Projects/Oligopoly/Program.cs b/Projects/Oligopoly/Program.cs index 066b3a61..2d7dca54 100644 --- a/Projects/Oligopoly/Program.cs +++ b/Projects/Oligopoly/Program.cs @@ -1,15 +1,18 @@ -using System.Xml; -using System.Xml.Serialization; +using System.Reflection; +using System.Text.Json; -namespace Oligopoly.Source +namespace Oligopoly { public class Program { - /// - /// Program entry point. - /// - /// The array of strings to process. - public static void Main(string[] args) + public static List Companies; + public static List Events; + + /// + /// Program entry point. + /// + /// The array of strings to process. + public static void Main(string[] args) { RunMainMenu(); } @@ -30,7 +33,7 @@ private static void RunMainMenu() "; string[] options = { "Play", "About", "Exit" }; - Menu mainMenu = new Menu(prompt, options, 0); + Menu mainMenu = new(prompt, options, 0); int selectedOption = mainMenu.RunMenu(); @@ -60,7 +63,7 @@ private static void RunSkipMenu() "; string[] options = { "Read introductory letter", "Skip introductory letter" }; - Menu skipMenu = new Menu(prompt, options, 0); + Menu skipMenu = new(prompt, options, 0); int selectedOption = skipMenu.RunMenu(); @@ -91,7 +94,7 @@ The board of directors of Oligopoly Investments "; string[] options = { "Get Access" }; - Menu startMenu = new Menu(prompt, options, 15); + Menu startMenu = new(prompt, options, 15); int selectedOption = startMenu.RunMenu(); @@ -109,75 +112,57 @@ The board of directors of Oligopoly Investments /// private static void RunGameMenu() { - // Create a Data class object, that contains game companies and events. - Data data = new Data(); - - // Read the .xml file. - try - { - XmlSerializer serializer = new XmlSerializer(typeof(Data)); - - using (Stream stream = File.Open("Data\\Data.xml", FileMode.Open)) - { - using (StreamReader reader = new StreamReader(stream)) - { - data = (Data)serializer.Deserialize(reader); - } - } - } - catch (InvalidOperationException ex) - { - Console.WriteLine($"Error! In file Data.xml specified invalid value."); - - if (ex.InnerException != null) - { - Console.WriteLine(ex.InnerException.Message); - } - } - catch (Exception ex) - { - Console.WriteLine($"Error! \nDetails: {ex.Message}"); - } - - // Create variables. - int currentEvent; + { + Assembly assembly = Assembly.GetExecutingAssembly(); + { + using Stream? stream = assembly.GetManifestResourceStream("Oligopoly.Company.json"); + Companies = JsonSerializer.Deserialize>(stream!)!; + } + { + using Stream? stream = assembly.GetManifestResourceStream("Oligopoly.Event.json"); + Events = JsonSerializer.Deserialize>(stream!)!; + } + } + + // Create variables. + int currentEvent; double money = 10000; bool isGameEnded = false; // Create a Random class object to generate event. - Random random = new Random(); + Random random = new(); // Start of the game cycle. while (!isGameEnded) { // Generate event for current turn. - currentEvent = random.Next(0, data.gameEvents.Count); + currentEvent = random.Next(0, Events.Count); // Determine current event's type. - if (data.gameEvents[currentEvent].Type == "Positive") // If current event is positive. + if (Events[currentEvent].Type == "Positive") // If current event is positive. { - foreach (var currentCompany in data.gameCompanies) + foreach (Company currentCompany in Companies) { - if (currentCompany.Ticker == data.gameEvents[currentEvent].Target) + if (currentCompany.Ticker == Events[currentEvent].Target) { - currentCompany.SharePrice = Math.Round(currentCompany.SharePrice + currentCompany.SharePrice * data.gameEvents[currentEvent].Effect / 100, 2); + currentCompany.SharePrice = Math.Round(currentCompany.SharePrice + currentCompany.SharePrice * Events[currentEvent].Effect / 100, 2); } } } - else if (data.gameEvents[currentEvent].Type == "Negative") // If current event is negative. + else if (Events[currentEvent].Type == "Negative") // If current event is negative. { - foreach (var currentCompany in data.gameCompanies) + foreach (Company currentCompany in Companies) { - if (currentCompany.Ticker == data.gameEvents[currentEvent].Target) + if (currentCompany.Ticker == Events[currentEvent].Target) { - currentCompany.SharePrice = Math.Round(currentCompany.SharePrice - currentCompany.SharePrice * data.gameEvents[currentEvent].Effect / 100, 2); + currentCompany.SharePrice = Math.Round(currentCompany.SharePrice - currentCompany.SharePrice * Events[currentEvent].Effect / 100, 2); } } } string prompt = "\nUse up and down arrow keys to select an option: \n"; string[] options = { "Skip", "Buy", "Sell", "More About Companies" }; - GameMenu gameMenu = new GameMenu(prompt, options, 0, currentEvent, money, data); + GameMenu gameMenu = new(prompt, options, 0, currentEvent, money); int selectedOption = gameMenu.RunMenu(); @@ -186,13 +171,13 @@ private static void RunGameMenu() case 0: break; case 1: - RunActionMenu(ref money, currentEvent, data, true); + RunActionMenu(ref money, currentEvent, true); break; case 2: - RunActionMenu(ref money, currentEvent, data, false); + RunActionMenu(ref money, currentEvent, false); break; case 3: - DisplayMoreAboutCompaniesMenu(data); + DisplayMoreAboutCompaniesMenu(); gameMenu.RunMenu(); break; } @@ -222,40 +207,40 @@ private static void RunGameMenu() /// The index of current generated event. /// An Data class object, that contain information about companies and events. /// Flag that determines the mode of the method. True - buying, false - selling. - private static void RunActionMenu(ref double money, int currentEvent, Data data, bool isBuying) + private static void RunActionMenu(ref double money, int currentEvent, bool isBuying) { string actionPrompt = "Select a company: \n"; string amountPrompt = "Select an amount: \n"; - string[] actionOptions = new string[data.gameCompanies.Count]; + string[] actionOptions = new string[Companies.Count]; string[] amountOptions = { "Increase (+)", "Decrease (-)", "Enter" }; for (int i = 0; i < actionOptions.Length; i++) { - actionOptions[i] = data.gameCompanies[i].Name; + actionOptions[i] = Companies[i].Name; } - GameMenu actionMenu = new GameMenu(actionPrompt, actionOptions, 0, currentEvent, money, data); - GameMenu amountMenu = new GameMenu(amountPrompt, amountOptions, 0, currentEvent, money, data); + GameMenu actionMenu = new(actionPrompt, actionOptions, 0, currentEvent, money); + GameMenu amountMenu = new(amountPrompt, amountOptions, 0, currentEvent, money); int selectedCompany = actionMenu.RunMenu(); int amountOfShares = amountMenu.RunAmountMenu(); if (isBuying) { - data.gameCompanies[selectedCompany].ShareAmount += amountOfShares; - money -= amountOfShares * data.gameCompanies[selectedCompany].SharePrice; + Companies[selectedCompany].ShareAmount += amountOfShares; + money -= amountOfShares * Companies[selectedCompany].SharePrice; - Console.WriteLine($"You have bought {amountOfShares} shares of {data.gameCompanies[selectedCompany].Name} company."); + Console.WriteLine($"You have bought {amountOfShares} shares of {Companies[selectedCompany].Name} company."); Thread.Sleep(2500); } else { - if (amountOfShares <= data.gameCompanies[selectedCompany].ShareAmount) + if (amountOfShares <= Companies[selectedCompany].ShareAmount) { - data.gameCompanies[selectedCompany].ShareAmount -= amountOfShares; - money += amountOfShares * data.gameCompanies[selectedCompany].SharePrice; + Companies[selectedCompany].ShareAmount -= amountOfShares; + money += amountOfShares * Companies[selectedCompany].SharePrice; - Console.WriteLine($"You have sold {amountOfShares} shares of {data.gameCompanies[selectedCompany].Name} company."); + Console.WriteLine($"You have sold {amountOfShares} shares of {Companies[selectedCompany].Name} company."); Thread.Sleep(2500); } else @@ -270,11 +255,11 @@ private static void RunActionMenu(ref double money, int currentEvent, Data data, /// Displays companies descriptions to the console. /// /// An Data class object, that contain information about companies and events. - private static void DisplayMoreAboutCompaniesMenu(Data data) + private static void DisplayMoreAboutCompaniesMenu() { Console.Clear(); - foreach (var company in data.gameCompanies) + foreach (Company company in Companies) { Console.WriteLine($"{company.Name} - {company.Description}\n"); } @@ -304,7 +289,7 @@ The board of directors of Oligopoly Investments "; string[] options = { "Play Again", "Return to Main Menu" }; - Menu EndMenu = new Menu(prompt, options, 15); + Menu EndMenu = new(prompt, options, 15); int selectedOption = EndMenu.RunMenu(); @@ -331,7 +316,7 @@ The board of directors of Oligopoly Investments "; string[] options = { "Play Again", "Return to Main Menu" }; - Menu EndMenu = new Menu(prompt, options, 15); + Menu EndMenu = new(prompt, options, 15); int selectedOption = EndMenu.RunMenu(); From 60035fc38d8b6c491773f32d0453ad14f48b1344 Mon Sep 17 00:00:00 2001 From: ZacharyPatten Date: Wed, 10 May 2023 17:08:56 -0500 Subject: [PATCH 07/18] disable implicit usings --- Projects/Oligopoly/GameMenu.cs | 5 +- Projects/Oligopoly/Menu.cs | 5 +- Projects/Oligopoly/Oligopoly.csproj | 2 +- Projects/Oligopoly/Program.cs | 590 ++++++++++++++-------------- 4 files changed, 306 insertions(+), 296 deletions(-) diff --git a/Projects/Oligopoly/GameMenu.cs b/Projects/Oligopoly/GameMenu.cs index adee201c..840e0da9 100644 --- a/Projects/Oligopoly/GameMenu.cs +++ b/Projects/Oligopoly/GameMenu.cs @@ -1,4 +1,7 @@ -namespace Oligopoly; +using System; +using System.Threading; + +namespace Oligopoly; public class GameMenu : Menu { diff --git a/Projects/Oligopoly/Menu.cs b/Projects/Oligopoly/Menu.cs index 558dc375..88c0b400 100644 --- a/Projects/Oligopoly/Menu.cs +++ b/Projects/Oligopoly/Menu.cs @@ -1,4 +1,7 @@ -namespace Oligopoly; +using System; +using System.Threading; + +namespace Oligopoly; public class Menu { diff --git a/Projects/Oligopoly/Oligopoly.csproj b/Projects/Oligopoly/Oligopoly.csproj index 45e819ff..0f06bb9f 100644 --- a/Projects/Oligopoly/Oligopoly.csproj +++ b/Projects/Oligopoly/Oligopoly.csproj @@ -2,7 +2,7 @@ Exe net6.0 - enable + disable enable diff --git a/Projects/Oligopoly/Program.cs b/Projects/Oligopoly/Program.cs index 2d7dca54..4fff5c2d 100644 --- a/Projects/Oligopoly/Program.cs +++ b/Projects/Oligopoly/Program.cs @@ -1,10 +1,14 @@ -using System.Reflection; +using System; +using System.Collections.Generic; +using System.IO; +using System.Reflection; using System.Text.Json; +using System.Threading; namespace Oligopoly { - public class Program - { + public class Program + { public static List Companies; public static List Events; @@ -12,17 +16,17 @@ public class Program /// Program entry point. /// /// The array of strings to process. - public static void Main(string[] args) - { - RunMainMenu(); - } - - /// - /// Runs the main menu of the game. - /// - private static void RunMainMenu() - { - string prompt = @" + public static void Main() + { + RunMainMenu(); + } + + /// + /// Runs the main menu of the game. + /// + private static void RunMainMenu() + { + string prompt = @" ██████╗ ██╗ ██╗ ██████╗ ██████╗ ██████╗ ██████╗ ██╗ ██╗ ██╗ ██╔═══██╗██║ ██║██╔════╝ ██╔═══██╗██╔══██╗██╔═══██╗██║ ╚██╗ ██╔╝ ██║ ██║██║ ██║██║ ███╗██║ ██║██████╔╝██║ ██║██║ ╚████╔╝ @@ -31,59 +35,59 @@ private static void RunMainMenu() ╚═════╝ ╚══════╝╚═╝ ╚═════╝ ╚═════╝ ╚═╝ ╚═════╝ ╚══════╝╚═╝ --Use up and down arrow keys to select an option-- "; - string[] options = { "Play", "About", "Exit" }; - - Menu mainMenu = new(prompt, options, 0); - - int selectedOption = mainMenu.RunMenu(); - - switch (selectedOption) - { - case 0: - RunSkipMenu(); - break; - case 1: - DisplayAboutInfo(); - RunMainMenu(); - break; - case 2: - ExitGame(); - break; - } - } - - /// - /// Runs skip menu. - /// - private static void RunSkipMenu() - { - string prompt = @"Welcome to Oligopoly! + string[] options = { "Play", "About", "Exit" }; + + Menu mainMenu = new(prompt, options, 0); + + int selectedOption = mainMenu.RunMenu(); + + switch (selectedOption) + { + case 0: + RunSkipMenu(); + break; + case 1: + DisplayAboutInfo(); + RunMainMenu(); + break; + case 2: + ExitGame(); + break; + } + } + + /// + /// Runs skip menu. + /// + private static void RunSkipMenu() + { + string prompt = @"Welcome to Oligopoly! Do you want to read the introductory letter or do you want to jump right into the gameplay? "; - string[] options = { "Read introductory letter", "Skip introductory letter" }; - - Menu skipMenu = new(prompt, options, 0); - - int selectedOption = skipMenu.RunMenu(); - - switch (selectedOption) - { - case 0: - RunStartMenu(); - break; - case 1: - RunGameMenu(); - break; - } - } - - /// - /// Runs the start menu of the game. - /// - private static void RunStartMenu() - { - string prompt = @"Dear, new CEO + string[] options = { "Read introductory letter", "Skip introductory letter" }; + + Menu skipMenu = new(prompt, options, 0); + + int selectedOption = skipMenu.RunMenu(); + + switch (selectedOption) + { + case 0: + RunStartMenu(); + break; + case 1: + RunGameMenu(); + break; + } + } + + /// + /// Runs the start menu of the game. + /// + private static void RunStartMenu() + { + string prompt = @"Dear, new CEO 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. @@ -92,26 +96,26 @@ private static void RunStartMenu() The board of directors of Oligopoly Investments "; - string[] options = { "Get Access" }; - - Menu startMenu = new(prompt, options, 15); - - int selectedOption = startMenu.RunMenu(); - - switch (selectedOption) - { - case 0: - Console.Clear(); - RunGameMenu(); - break; - } - } - - /// - /// Runs the game menu. - /// - private static void RunGameMenu() - { + string[] options = { "Get Access" }; + + Menu startMenu = new(prompt, options, 15); + + int selectedOption = startMenu.RunMenu(); + + switch (selectedOption) + { + case 0: + Console.Clear(); + RunGameMenu(); + break; + } + } + + /// + /// Runs the game menu. + /// + private static void RunGameMenu() + { { Assembly assembly = Assembly.GetExecutingAssembly(); { @@ -126,159 +130,159 @@ private static void RunGameMenu() // Create variables. int currentEvent; - double money = 10000; - bool isGameEnded = false; - - // Create a Random class object to generate event. - Random random = new(); - - // Start of the game cycle. - while (!isGameEnded) - { - // Generate event for current turn. - currentEvent = random.Next(0, Events.Count); - - // Determine current event's type. - if (Events[currentEvent].Type == "Positive") // If current event is positive. - { - foreach (Company currentCompany in Companies) - { - if (currentCompany.Ticker == Events[currentEvent].Target) - { - currentCompany.SharePrice = Math.Round(currentCompany.SharePrice + currentCompany.SharePrice * Events[currentEvent].Effect / 100, 2); - } - } - } - else if (Events[currentEvent].Type == "Negative") // If current event is negative. - { - foreach (Company currentCompany in Companies) - { - if (currentCompany.Ticker == Events[currentEvent].Target) - { - currentCompany.SharePrice = Math.Round(currentCompany.SharePrice - currentCompany.SharePrice * Events[currentEvent].Effect / 100, 2); - } - } - } - - string prompt = "\nUse up and down arrow keys to select an option: \n"; - string[] options = { "Skip", "Buy", "Sell", "More About Companies" }; - GameMenu gameMenu = new(prompt, options, 0, currentEvent, money); - - int selectedOption = gameMenu.RunMenu(); - - switch (selectedOption) - { - case 0: - break; - case 1: - RunActionMenu(ref money, currentEvent, true); - break; - case 2: - RunActionMenu(ref money, currentEvent, false); - break; - case 3: - DisplayMoreAboutCompaniesMenu(); - gameMenu.RunMenu(); - break; - } - - // Check for win or loss. - if (money <= 0) - { - isGameEnded = true; - RunEndMenu(false); - } - else if (money >= 50000) - { - isGameEnded = true; - RunEndMenu(true); - } - else - { - continue; - } - } - } - - /// - /// Runs action menu, that is buying or selling menu. - /// - /// The amount of money that user currently has. - /// The index of current generated event. - /// An Data class object, that contain information about companies and events. - /// Flag that determines the mode of the method. True - buying, false - selling. - private static void RunActionMenu(ref double money, int currentEvent, bool isBuying) - { - string actionPrompt = "Select a company: \n"; - string amountPrompt = "Select an amount: \n"; - string[] actionOptions = new string[Companies.Count]; - string[] amountOptions = { "Increase (+)", "Decrease (-)", "Enter" }; - - for (int i = 0; i < actionOptions.Length; i++) - { - actionOptions[i] = Companies[i].Name; - } - - GameMenu actionMenu = new(actionPrompt, actionOptions, 0, currentEvent, money); - GameMenu amountMenu = new(amountPrompt, amountOptions, 0, currentEvent, money); - - int selectedCompany = actionMenu.RunMenu(); - int amountOfShares = amountMenu.RunAmountMenu(); - - if (isBuying) - { + double money = 10000; + bool isGameEnded = false; + + // Create a Random class object to generate event. + Random random = new(); + + // Start of the game cycle. + while (!isGameEnded) + { + // Generate event for current turn. + currentEvent = random.Next(0, Events.Count); + + // Determine current event's type. + if (Events[currentEvent].Type == "Positive") // If current event is positive. + { + foreach (Company currentCompany in Companies) + { + if (currentCompany.Ticker == Events[currentEvent].Target) + { + currentCompany.SharePrice = Math.Round(currentCompany.SharePrice + currentCompany.SharePrice * Events[currentEvent].Effect / 100, 2); + } + } + } + else if (Events[currentEvent].Type == "Negative") // If current event is negative. + { + foreach (Company currentCompany in Companies) + { + if (currentCompany.Ticker == Events[currentEvent].Target) + { + currentCompany.SharePrice = Math.Round(currentCompany.SharePrice - currentCompany.SharePrice * Events[currentEvent].Effect / 100, 2); + } + } + } + + string prompt = "\nUse up and down arrow keys to select an option: \n"; + string[] options = { "Skip", "Buy", "Sell", "More About Companies" }; + GameMenu gameMenu = new(prompt, options, 0, currentEvent, money); + + int selectedOption = gameMenu.RunMenu(); + + switch (selectedOption) + { + case 0: + break; + case 1: + RunActionMenu(ref money, currentEvent, true); + break; + case 2: + RunActionMenu(ref money, currentEvent, false); + break; + case 3: + DisplayMoreAboutCompaniesMenu(); + gameMenu.RunMenu(); + break; + } + + // Check for win or loss. + if (money <= 0) + { + isGameEnded = true; + RunEndMenu(false); + } + else if (money >= 50000) + { + isGameEnded = true; + RunEndMenu(true); + } + else + { + continue; + } + } + } + + /// + /// Runs action menu, that is buying or selling menu. + /// + /// The amount of money that user currently has. + /// The index of current generated event. + /// An Data class object, that contain information about companies and events. + /// Flag that determines the mode of the method. True - buying, false - selling. + private static void RunActionMenu(ref double money, int currentEvent, bool isBuying) + { + string actionPrompt = "Select a company: \n"; + string amountPrompt = "Select an amount: \n"; + string[] actionOptions = new string[Companies.Count]; + string[] amountOptions = { "Increase (+)", "Decrease (-)", "Enter" }; + + for (int i = 0; i < actionOptions.Length; i++) + { + actionOptions[i] = Companies[i].Name; + } + + GameMenu actionMenu = new(actionPrompt, actionOptions, 0, currentEvent, money); + GameMenu amountMenu = new(amountPrompt, amountOptions, 0, currentEvent, money); + + int selectedCompany = actionMenu.RunMenu(); + int amountOfShares = amountMenu.RunAmountMenu(); + + if (isBuying) + { Companies[selectedCompany].ShareAmount += amountOfShares; - money -= amountOfShares * Companies[selectedCompany].SharePrice; - - Console.WriteLine($"You have bought {amountOfShares} shares of {Companies[selectedCompany].Name} company."); - Thread.Sleep(2500); - } - else - { - if (amountOfShares <= Companies[selectedCompany].ShareAmount) - { + money -= amountOfShares * Companies[selectedCompany].SharePrice; + + Console.WriteLine($"You have bought {amountOfShares} shares of {Companies[selectedCompany].Name} company."); + Thread.Sleep(2500); + } + else + { + if (amountOfShares <= Companies[selectedCompany].ShareAmount) + { Companies[selectedCompany].ShareAmount -= amountOfShares; - money += amountOfShares * Companies[selectedCompany].SharePrice; - - Console.WriteLine($"You have sold {amountOfShares} shares of {Companies[selectedCompany].Name} company."); - Thread.Sleep(2500); - } - else - { - Console.WriteLine("Entered not a valid value"); - Thread.Sleep(2500); - } - } - } - - /// - /// Displays companies descriptions to the console. - /// - /// An Data class object, that contain information about companies and events. - private static void DisplayMoreAboutCompaniesMenu() - { - Console.Clear(); - - foreach (Company company in Companies) - { - Console.WriteLine($"{company.Name} - {company.Description}\n"); - } - - Console.WriteLine("Press any key to exit the menu..."); - Console.ReadKey(true); - } - - /// - /// Runs end menu. - /// - /// Flag that determines the mode of the method. True - for a winner, false - for a loser. - private static void RunEndMenu(bool isWinner) - { - Console.Clear(); - - if (isWinner) - { - string prompt = @"Dear CEO, + money += amountOfShares * Companies[selectedCompany].SharePrice; + + Console.WriteLine($"You have sold {amountOfShares} shares of {Companies[selectedCompany].Name} company."); + Thread.Sleep(2500); + } + else + { + Console.WriteLine("Entered not a valid value"); + Thread.Sleep(2500); + } + } + } + + /// + /// Displays companies descriptions to the console. + /// + /// An Data class object, that contain information about companies and events. + private static void DisplayMoreAboutCompaniesMenu() + { + Console.Clear(); + + foreach (Company company in Companies) + { + Console.WriteLine($"{company.Name} - {company.Description}\n"); + } + + Console.WriteLine("Press any key to exit the menu..."); + Console.ReadKey(true); + } + + /// + /// Runs end menu. + /// + /// Flag that determines the mode of the method. True - for a winner, false - for a loser. + private static void RunEndMenu(bool isWinner) + { + Console.Clear(); + + if (isWinner) + { + string prompt = @"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. @@ -287,25 +291,25 @@ private static void RunEndMenu(bool isWinner) The board of directors of Oligopoly Investments "; - string[] options = { "Play Again", "Return to Main Menu" }; - - Menu EndMenu = new(prompt, options, 15); - - int selectedOption = EndMenu.RunMenu(); - - switch (selectedOption) - { - case 0: - RunGameMenu(); - break; - case 1: - RunMainMenu(); - break; - } - } - else - { - string prompt = @"Dear, former CEO + string[] options = { "Play Again", "Return to Main Menu" }; + + Menu EndMenu = new(prompt, options, 15); + + int selectedOption = EndMenu.RunMenu(); + + switch (selectedOption) + { + case 0: + RunGameMenu(); + break; + case 1: + RunMainMenu(); + break; + } + } + else + { + string prompt = @"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. @@ -314,49 +318,49 @@ We appreciate your service and wish you all the best in your future endeavors. The board of directors of Oligopoly Investments "; - string[] options = { "Play Again", "Return to Main Menu" }; - - Menu EndMenu = new(prompt, options, 15); - - int selectedOption = EndMenu.RunMenu(); - - switch (selectedOption) - { - case 0: - RunGameMenu(); - break; - case 1: - RunMainMenu(); - break; - } - } - } - - /// - /// Displays information about the game. - /// - private static void DisplayAboutInfo() - { - Console.Clear(); - Console.WriteLine(@"THANKS! + string[] options = { "Play Again", "Return to Main Menu" }; + + Menu EndMenu = new(prompt, options, 15); + + int selectedOption = EndMenu.RunMenu(); + + switch (selectedOption) + { + case 0: + RunGameMenu(); + break; + case 1: + RunMainMenu(); + break; + } + } + } + + /// + /// Displays information about the game. + /// + private static void DisplayAboutInfo() + { + Console.Clear(); + Console.WriteLine(@"THANKS! No really, thank you for taking time to play this simple console game. It means a lot. This game was created by Semion Medvedev (Fuinny) My GitHub profile: https://github.com/Fuinny Press any key to exit the menu..."); - Console.ReadKey(true); - } - - /// - /// Exits the game. - /// - private static void ExitGame() - { - Console.Clear(); - Console.WriteLine("Press any key to exit the game..."); - Console.ReadKey(true); - Environment.Exit(0); - } - } + Console.ReadKey(true); + } + + /// + /// Exits the game. + /// + private static void ExitGame() + { + Console.Clear(); + Console.WriteLine("Press any key to exit the game..."); + Console.ReadKey(true); + Environment.Exit(0); + } + } } \ No newline at end of file From 0e7c78d0fe8592cc392a6f1f9ef1d91c8931c2a3 Mon Sep 17 00:00:00 2001 From: ZacharyPatten Date: Wed, 10 May 2023 17:10:53 -0500 Subject: [PATCH 08/18] file scoped namespace --- Projects/Oligopoly/Program.cs | 491 +++++++++++++++++----------------- 1 file changed, 245 insertions(+), 246 deletions(-) diff --git a/Projects/Oligopoly/Program.cs b/Projects/Oligopoly/Program.cs index 4fff5c2d..6407f517 100644 --- a/Projects/Oligopoly/Program.cs +++ b/Projects/Oligopoly/Program.cs @@ -5,28 +5,28 @@ using System.Text.Json; using System.Threading; -namespace Oligopoly +namespace Oligopoly; + +public class Program { - public class Program + public static List Companies; + public static List Events; + + /// + /// Program entry point. + /// + /// The array of strings to process. + public static void Main() { - public static List Companies; - public static List Events; - - /// - /// Program entry point. - /// - /// The array of strings to process. - public static void Main() - { - RunMainMenu(); - } + RunMainMenu(); + } - /// - /// Runs the main menu of the game. - /// - private static void RunMainMenu() - { - string prompt = @" + /// + /// Runs the main menu of the game. + /// + private static void RunMainMenu() + { + string prompt = @" ██████╗ ██╗ ██╗ ██████╗ ██████╗ ██████╗ ██████╗ ██╗ ██╗ ██╗ ██╔═══██╗██║ ██║██╔════╝ ██╔═══██╗██╔══██╗██╔═══██╗██║ ╚██╗ ██╔╝ ██║ ██║██║ ██║██║ ███╗██║ ██║██████╔╝██║ ██║██║ ╚████╔╝ @@ -35,59 +35,59 @@ private static void RunMainMenu() ╚═════╝ ╚══════╝╚═╝ ╚═════╝ ╚═════╝ ╚═╝ ╚═════╝ ╚══════╝╚═╝ --Use up and down arrow keys to select an option-- "; - string[] options = { "Play", "About", "Exit" }; + string[] options = { "Play", "About", "Exit" }; - Menu mainMenu = new(prompt, options, 0); + Menu mainMenu = new(prompt, options, 0); - int selectedOption = mainMenu.RunMenu(); + int selectedOption = mainMenu.RunMenu(); - switch (selectedOption) - { - case 0: - RunSkipMenu(); - break; - case 1: - DisplayAboutInfo(); - RunMainMenu(); - break; - case 2: - ExitGame(); - break; - } + switch (selectedOption) + { + case 0: + RunSkipMenu(); + break; + case 1: + DisplayAboutInfo(); + RunMainMenu(); + break; + case 2: + ExitGame(); + break; } + } - /// - /// Runs skip menu. - /// - private static void RunSkipMenu() - { - string prompt = @"Welcome to Oligopoly! + /// + /// Runs skip menu. + /// + private static void RunSkipMenu() + { + string prompt = @"Welcome to Oligopoly! Do you want to read the introductory letter or do you want to jump right into the gameplay? "; - string[] options = { "Read introductory letter", "Skip introductory letter" }; + string[] options = { "Read introductory letter", "Skip introductory letter" }; - Menu skipMenu = new(prompt, options, 0); + Menu skipMenu = new(prompt, options, 0); - int selectedOption = skipMenu.RunMenu(); + int selectedOption = skipMenu.RunMenu(); - switch (selectedOption) - { - case 0: - RunStartMenu(); - break; - case 1: - RunGameMenu(); - break; - } + switch (selectedOption) + { + case 0: + RunStartMenu(); + break; + case 1: + RunGameMenu(); + break; } + } - /// - /// Runs the start menu of the game. - /// - private static void RunStartMenu() - { - string prompt = @"Dear, new CEO + /// + /// Runs the start menu of the game. + /// + private static void RunStartMenu() + { + string prompt = @"Dear, new CEO 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. @@ -96,193 +96,193 @@ private static void RunStartMenu() The board of directors of Oligopoly Investments "; - string[] options = { "Get Access" }; + string[] options = { "Get Access" }; - Menu startMenu = new(prompt, options, 15); + Menu startMenu = new(prompt, options, 15); - int selectedOption = startMenu.RunMenu(); + int selectedOption = startMenu.RunMenu(); - switch (selectedOption) - { - case 0: - Console.Clear(); - RunGameMenu(); - break; - } + switch (selectedOption) + { + case 0: + Console.Clear(); + RunGameMenu(); + break; } + } - /// - /// Runs the game menu. - /// - private static void RunGameMenu() + /// + /// Runs the game menu. + /// + private static void RunGameMenu() + { { + Assembly assembly = Assembly.GetExecutingAssembly(); { - Assembly assembly = Assembly.GetExecutingAssembly(); - { - using Stream? stream = assembly.GetManifestResourceStream("Oligopoly.Company.json"); - Companies = JsonSerializer.Deserialize>(stream!)!; - } - { - using Stream? stream = assembly.GetManifestResourceStream("Oligopoly.Event.json"); - Events = JsonSerializer.Deserialize>(stream!)!; - } + using Stream? stream = assembly.GetManifestResourceStream("Oligopoly.Company.json"); + Companies = JsonSerializer.Deserialize>(stream!)!; + } + { + using Stream? stream = assembly.GetManifestResourceStream("Oligopoly.Event.json"); + Events = JsonSerializer.Deserialize>(stream!)!; } + } - // Create variables. - int currentEvent; - double money = 10000; - bool isGameEnded = false; + // Create variables. + int currentEvent; + double money = 10000; + bool isGameEnded = false; - // Create a Random class object to generate event. - Random random = new(); + // Create a Random class object to generate event. + Random random = new(); - // Start of the game cycle. - while (!isGameEnded) - { - // Generate event for current turn. - currentEvent = random.Next(0, Events.Count); + // Start of the game cycle. + while (!isGameEnded) + { + // Generate event for current turn. + currentEvent = random.Next(0, Events.Count); - // Determine current event's type. - if (Events[currentEvent].Type == "Positive") // If current event is positive. + // Determine current event's type. + if (Events[currentEvent].Type == "Positive") // If current event is positive. + { + foreach (Company currentCompany in Companies) { - foreach (Company currentCompany in Companies) + if (currentCompany.Ticker == Events[currentEvent].Target) { - if (currentCompany.Ticker == Events[currentEvent].Target) - { - currentCompany.SharePrice = Math.Round(currentCompany.SharePrice + currentCompany.SharePrice * Events[currentEvent].Effect / 100, 2); - } + currentCompany.SharePrice = Math.Round(currentCompany.SharePrice + currentCompany.SharePrice * Events[currentEvent].Effect / 100, 2); } } - else if (Events[currentEvent].Type == "Negative") // If current event is negative. + } + else if (Events[currentEvent].Type == "Negative") // If current event is negative. + { + foreach (Company currentCompany in Companies) { - foreach (Company currentCompany in Companies) + if (currentCompany.Ticker == Events[currentEvent].Target) { - if (currentCompany.Ticker == Events[currentEvent].Target) - { - currentCompany.SharePrice = Math.Round(currentCompany.SharePrice - currentCompany.SharePrice * Events[currentEvent].Effect / 100, 2); - } + currentCompany.SharePrice = Math.Round(currentCompany.SharePrice - currentCompany.SharePrice * Events[currentEvent].Effect / 100, 2); } } + } - string prompt = "\nUse up and down arrow keys to select an option: \n"; - string[] options = { "Skip", "Buy", "Sell", "More About Companies" }; - GameMenu gameMenu = new(prompt, options, 0, currentEvent, money); + string prompt = "\nUse up and down arrow keys to select an option: \n"; + string[] options = { "Skip", "Buy", "Sell", "More About Companies" }; + GameMenu gameMenu = new(prompt, options, 0, currentEvent, money); - int selectedOption = gameMenu.RunMenu(); + int selectedOption = gameMenu.RunMenu(); - switch (selectedOption) - { - case 0: - break; - case 1: - RunActionMenu(ref money, currentEvent, true); - break; - case 2: - RunActionMenu(ref money, currentEvent, false); - break; - case 3: - DisplayMoreAboutCompaniesMenu(); - gameMenu.RunMenu(); - break; - } + switch (selectedOption) + { + case 0: + break; + case 1: + RunActionMenu(ref money, currentEvent, true); + break; + case 2: + RunActionMenu(ref money, currentEvent, false); + break; + case 3: + DisplayMoreAboutCompaniesMenu(); + gameMenu.RunMenu(); + break; + } - // Check for win or loss. - if (money <= 0) - { - isGameEnded = true; - RunEndMenu(false); - } - else if (money >= 50000) - { - isGameEnded = true; - RunEndMenu(true); - } - else - { - continue; - } + // Check for win or loss. + if (money <= 0) + { + isGameEnded = true; + RunEndMenu(false); + } + else if (money >= 50000) + { + isGameEnded = true; + RunEndMenu(true); + } + else + { + continue; } } + } + + /// + /// Runs action menu, that is buying or selling menu. + /// + /// The amount of money that user currently has. + /// The index of current generated event. + /// An Data class object, that contain information about companies and events. + /// Flag that determines the mode of the method. True - buying, false - selling. + private static void RunActionMenu(ref double money, int currentEvent, bool isBuying) + { + string actionPrompt = "Select a company: \n"; + string amountPrompt = "Select an amount: \n"; + string[] actionOptions = new string[Companies.Count]; + string[] amountOptions = { "Increase (+)", "Decrease (-)", "Enter" }; - /// - /// Runs action menu, that is buying or selling menu. - /// - /// The amount of money that user currently has. - /// The index of current generated event. - /// An Data class object, that contain information about companies and events. - /// Flag that determines the mode of the method. True - buying, false - selling. - private static void RunActionMenu(ref double money, int currentEvent, bool isBuying) + for (int i = 0; i < actionOptions.Length; i++) { - string actionPrompt = "Select a company: \n"; - string amountPrompt = "Select an amount: \n"; - string[] actionOptions = new string[Companies.Count]; - string[] amountOptions = { "Increase (+)", "Decrease (-)", "Enter" }; + actionOptions[i] = Companies[i].Name; + } - for (int i = 0; i < actionOptions.Length; i++) - { - actionOptions[i] = Companies[i].Name; - } + GameMenu actionMenu = new(actionPrompt, actionOptions, 0, currentEvent, money); + GameMenu amountMenu = new(amountPrompt, amountOptions, 0, currentEvent, money); - GameMenu actionMenu = new(actionPrompt, actionOptions, 0, currentEvent, money); - GameMenu amountMenu = new(amountPrompt, amountOptions, 0, currentEvent, money); + int selectedCompany = actionMenu.RunMenu(); + int amountOfShares = amountMenu.RunAmountMenu(); - int selectedCompany = actionMenu.RunMenu(); - int amountOfShares = amountMenu.RunAmountMenu(); + if (isBuying) + { + Companies[selectedCompany].ShareAmount += amountOfShares; + money -= amountOfShares * Companies[selectedCompany].SharePrice; - if (isBuying) + Console.WriteLine($"You have bought {amountOfShares} shares of {Companies[selectedCompany].Name} company."); + Thread.Sleep(2500); + } + else + { + if (amountOfShares <= Companies[selectedCompany].ShareAmount) { - Companies[selectedCompany].ShareAmount += amountOfShares; - money -= amountOfShares * Companies[selectedCompany].SharePrice; + Companies[selectedCompany].ShareAmount -= amountOfShares; + money += amountOfShares * Companies[selectedCompany].SharePrice; - Console.WriteLine($"You have bought {amountOfShares} shares of {Companies[selectedCompany].Name} company."); + Console.WriteLine($"You have sold {amountOfShares} shares of {Companies[selectedCompany].Name} company."); Thread.Sleep(2500); } else { - if (amountOfShares <= Companies[selectedCompany].ShareAmount) - { - Companies[selectedCompany].ShareAmount -= amountOfShares; - money += amountOfShares * Companies[selectedCompany].SharePrice; - - Console.WriteLine($"You have sold {amountOfShares} shares of {Companies[selectedCompany].Name} company."); - Thread.Sleep(2500); - } - else - { - Console.WriteLine("Entered not a valid value"); - Thread.Sleep(2500); - } + Console.WriteLine("Entered not a valid value"); + Thread.Sleep(2500); } } + } - /// - /// Displays companies descriptions to the console. - /// - /// An Data class object, that contain information about companies and events. - private static void DisplayMoreAboutCompaniesMenu() + /// + /// Displays companies descriptions to the console. + /// + /// An Data class object, that contain information about companies and events. + private static void DisplayMoreAboutCompaniesMenu() + { + Console.Clear(); + + foreach (Company company in Companies) { - Console.Clear(); + Console.WriteLine($"{company.Name} - {company.Description}\n"); + } - foreach (Company company in Companies) - { - Console.WriteLine($"{company.Name} - {company.Description}\n"); - } + Console.WriteLine("Press any key to exit the menu..."); + Console.ReadKey(true); + } - Console.WriteLine("Press any key to exit the menu..."); - Console.ReadKey(true); - } + /// + /// Runs end menu. + /// + /// Flag that determines the mode of the method. True - for a winner, false - for a loser. + private static void RunEndMenu(bool isWinner) + { + Console.Clear(); - /// - /// Runs end menu. - /// - /// Flag that determines the mode of the method. True - for a winner, false - for a loser. - private static void RunEndMenu(bool isWinner) + if (isWinner) { - Console.Clear(); - - if (isWinner) - { - string prompt = @"Dear CEO, + string prompt = @"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. @@ -291,25 +291,25 @@ private static void RunEndMenu(bool isWinner) The board of directors of Oligopoly Investments "; - string[] options = { "Play Again", "Return to Main Menu" }; + string[] options = { "Play Again", "Return to Main Menu" }; - Menu EndMenu = new(prompt, options, 15); + Menu EndMenu = new(prompt, options, 15); - int selectedOption = EndMenu.RunMenu(); + int selectedOption = EndMenu.RunMenu(); - switch (selectedOption) - { - case 0: - RunGameMenu(); - break; - case 1: - RunMainMenu(); - break; - } - } - else + switch (selectedOption) { - string prompt = @"Dear, former CEO + case 0: + RunGameMenu(); + break; + case 1: + RunMainMenu(); + break; + } + } + else + { + string prompt = @"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. @@ -318,49 +318,48 @@ We appreciate your service and wish you all the best in your future endeavors. The board of directors of Oligopoly Investments "; - string[] options = { "Play Again", "Return to Main Menu" }; + string[] options = { "Play Again", "Return to Main Menu" }; - Menu EndMenu = new(prompt, options, 15); + Menu EndMenu = new(prompt, options, 15); - int selectedOption = EndMenu.RunMenu(); + int selectedOption = EndMenu.RunMenu(); - switch (selectedOption) - { - case 0: - RunGameMenu(); - break; - case 1: - RunMainMenu(); - break; - } + switch (selectedOption) + { + case 0: + RunGameMenu(); + break; + case 1: + RunMainMenu(); + break; } } + } - /// - /// Displays information about the game. - /// - private static void DisplayAboutInfo() - { - Console.Clear(); - Console.WriteLine(@"THANKS! + /// + /// Displays information about the game. + /// + private static void DisplayAboutInfo() + { + Console.Clear(); + Console.WriteLine(@"THANKS! No really, thank you for taking time to play this simple console game. It means a lot. This game was created by Semion Medvedev (Fuinny) My GitHub profile: https://github.com/Fuinny Press any key to exit the menu..."); - Console.ReadKey(true); - } + Console.ReadKey(true); + } - /// - /// Exits the game. - /// - private static void ExitGame() - { - Console.Clear(); - Console.WriteLine("Press any key to exit the game..."); - Console.ReadKey(true); - Environment.Exit(0); - } + /// + /// Exits the game. + /// + private static void ExitGame() + { + Console.Clear(); + Console.WriteLine("Press any key to exit the game..."); + Console.ReadKey(true); + Environment.Exit(0); } } \ No newline at end of file From 08efdac471b6de95e44b56d20f6fca7fc0f78d50 Mon Sep 17 00:00:00 2001 From: ZacharyPatten Date: Wed, 10 May 2023 18:05:49 -0500 Subject: [PATCH 09/18] clean up --- Projects/Oligopoly/GameMenu.cs | 169 ++++++++++----------------------- Projects/Oligopoly/Menu.cs | 43 ++------- Projects/Oligopoly/Program.cs | 51 ++-------- 3 files changed, 63 insertions(+), 200 deletions(-) diff --git a/Projects/Oligopoly/GameMenu.cs b/Projects/Oligopoly/GameMenu.cs index 840e0da9..d0cddc66 100644 --- a/Projects/Oligopoly/GameMenu.cs +++ b/Projects/Oligopoly/GameMenu.cs @@ -15,7 +15,6 @@ public class GameMenu : Menu /// The options to display in the menu. /// The text output delay. Have to be a positive integer or zero. /// The integer that represents current event. - /// The Data class object, which contains all companies and events. public GameMenu(string prompt, string[] options, int outputDelay, int currentEvent, double money) : base(prompt, options, outputDelay) { @@ -28,57 +27,37 @@ public GameMenu(string prompt, string[] options, int outputDelay, int currentEve /// protected override void DisplayMenu() { - // Display amount of money. - Console.WriteLine(string.Format($"You have: {Math.Round(Money, 2)}$\n", -50)); - - // Display current event. - Console.WriteLine($"{Program.Events[CurrentEvent].Title}"); - Console.WriteLine($"\n{Program.Events[CurrentEvent].Content}\n"); - - // Display companies. - Console.Write("╔"); - for (int i = 0; i < 120 - 2; i++) - { - Console.Write("═"); - } - Console.WriteLine("╗"); - - Console.WriteLine(string.Format($"{"║ Company",-52} ║ {"Ticker",8} ║ {"Industry",10} ║ {"Share Price",19} ║ {"You Have",17} ║")); - - Console.Write("╚"); - for (int i = 0; i < 120 - 2; i++) - { - Console.Write("═"); - } - Console.WriteLine("╝"); - - Console.Write("╔"); - for (int i = 0; i < 120 - 2; i++) - { - Console.Write("═"); - } - Console.WriteLine("╗"); - + // column widths + const int c0 = 30; + const int c1 = 8; + const int c2 = 10; + const int c3 = 19; + const int c4 = 17; + + Console.WriteLine($"╔═{new('═', c0)}═╤═{new('═', c1)}═╤═{new('═', c2)}═╤═{new('═', c3)}═╤═{new('═', c4)}═╗"); + Console.WriteLine($"║ {"Company", -c0} │ {"Ticker", c1} │ {"Industry", c2} │ {"Share Price", c3} │ {"You Have", c4} ║"); + Console.WriteLine($"╟─{new('─', c0)}─┼─{new('─', c1)}─┼─{new('─', c2)}─┼─{new('─', c3)}─┼─{new('─', c4)}─╢"); foreach (Company company in Program.Companies) { - Console.WriteLine(string.Format($"║ {company.Name,-50} ║ {company.Ticker,8} ║ {company.Industry,10} ║ {company.SharePrice,19} ║ {company.ShareAmount,17} ║")); + Console.WriteLine($"║ {company.Name, -c0} │ {company.Ticker, c1} │ {company.Industry, c2} │ {company.SharePrice, c3} │ {company.ShareAmount, c4} ║"); } + Console.WriteLine($"╚═{new('═', c0)}═╧═{new('═', c1)}═╧═{new('═', c2)}═╧═{new('═', c3)}═╧═{new('═', c4)}═╝"); + Console.WriteLine(); - Console.Write("╚"); - for (int i = 0; i < 120 - 2; i++) - { - Console.Write("═"); - } - Console.WriteLine("╝"); + Console.WriteLine($"{Program.Events[CurrentEvent].Title}"); + Console.WriteLine(); + Console.WriteLine($"{Program.Events[CurrentEvent].Content}"); + Console.WriteLine(); + + Console.WriteLine($"You have: {Math.Round(Money, 2)}$"); + //Console.WriteLine(); - // Display the prompt above the menu. foreach (char symbol in Prompt) { Thread.Sleep(OutputDelay); Console.Write(symbol); } - // Display all options inside the menu and redraw it when user select other option. for (int i = 0; i < Options.Length; i++) { string currentOption = Options[i]; @@ -113,45 +92,22 @@ public override int RunMenu() // This is necessary so that the menu does not draw with a delay when updating the console. OutputDelay = 0; - // Create variable, that contains key that was pressed. - ConsoleKey keyPressed; - - do + ConsoleKey keyPressed = default; + while (keyPressed is not ConsoleKey.Enter) { - // Redraw the menu. Console.Clear(); DisplayMenu(); - - //Read the user's input. - ConsoleKeyInfo keyInfo = Console.ReadKey(); - - // Get the key that was pressed. - keyPressed = keyInfo.Key; - - // Move the selection up or down, based on the pressed key. - if (keyPressed == ConsoleKey.UpArrow) + keyPressed = Console.ReadKey().Key; + if (keyPressed is ConsoleKey.UpArrow) { - SelectedIndex--; - - // Wrap around if user is out of range. - if (SelectedIndex == -1) - { - SelectedIndex = Options.Length - 1; - } + SelectedIndex = SelectedIndex is 0 ? Options.Length - 1 : SelectedIndex - 1; } - else if (keyPressed == ConsoleKey.DownArrow) + else if (keyPressed is ConsoleKey.DownArrow) { - SelectedIndex++; - - // Wrap around if user is out of range. - if (SelectedIndex == Options.Length) - { - SelectedIndex = 0; - } + SelectedIndex = SelectedIndex == Options.Length - 1 ? 0 : SelectedIndex + 1; } - } while (keyPressed != ConsoleKey.Enter); + } - // Return the selected option. return SelectedIndex; } @@ -165,62 +121,35 @@ public int RunAmountMenu() // This is necessary so that the menu does not draw with a delay when updating the console. OutputDelay = 0; - // Create variable, that contains key that was pressed. - ConsoleKey keyPressed; - + ConsoleKey keyPressed = default; int amount = 0; - - do + while (keyPressed is not ConsoleKey.Enter || SelectedIndex is not 2) { - // Redraw the menu. Console.Clear(); DisplayMenu(); - - // Display current amount of shares. Console.WriteLine($"Current amount: {amount}"); - - //Read the user's input. - ConsoleKeyInfo keyInfo = Console.ReadKey(); - - // Get the key that was pressed. - keyPressed = keyInfo.Key; - - // Move the selection up or down, based on the pressed key. - if (keyPressed == ConsoleKey.UpArrow) + keyPressed = Console.ReadKey().Key; + switch (keyPressed) { - SelectedIndex--; - - // Wrap around if user is out of range. - if (SelectedIndex == -1) - { - SelectedIndex = Options.Length - 1; - } - } - else if (keyPressed == ConsoleKey.DownArrow) - { - SelectedIndex++; - - // Wrap around if user is out of range. - if (SelectedIndex == Options.Length) - { - SelectedIndex = 0; - } - } - - if (keyPressed == ConsoleKey.Enter && SelectedIndex == 0) - { - amount++; + case ConsoleKey.UpArrow: + SelectedIndex = SelectedIndex is 0 ? Options.Length - 1 : SelectedIndex - 1; + break; + case ConsoleKey.DownArrow: + SelectedIndex = SelectedIndex == Options.Length - 1 ? 0 : SelectedIndex + 1; + break; + case ConsoleKey.Enter: + if (SelectedIndex is 0) + { + amount++; + } + else if (SelectedIndex is 1 && amount > 0) + { + amount--; + } + break; } - else if (keyPressed == ConsoleKey.Enter && SelectedIndex == 1) - { - if (amount > 0) - { - amount--; - } - } - } while (!(keyPressed == ConsoleKey.Enter && SelectedIndex == 2)); + } - // Return the amount of shares. return amount; } } \ No newline at end of file diff --git a/Projects/Oligopoly/Menu.cs b/Projects/Oligopoly/Menu.cs index 88c0b400..1bb138ea 100644 --- a/Projects/Oligopoly/Menu.cs +++ b/Projects/Oligopoly/Menu.cs @@ -5,7 +5,6 @@ namespace Oligopoly; public class Menu { - // Create a class fields. protected int SelectedIndex; protected int OutputDelay; protected string Prompt; @@ -30,14 +29,12 @@ public Menu(string prompt, string[] options, int outputDelay) /// protected virtual void DisplayMenu() { - // Display the prompt above the menu. foreach (char symbol in Prompt) { Thread.Sleep(OutputDelay); Console.Write(symbol); } - // Display all options inside the menu and redraw it when user select other option. for (int i = 0; i < Options.Length; i++) { string currentOption = Options[i]; @@ -58,8 +55,6 @@ protected virtual void DisplayMenu() Console.WriteLine($"[{prefix}] {currentOption}"); } - - // Reset console colors. Console.ResetColor(); } @@ -73,45 +68,23 @@ public virtual int RunMenu() // This is necessary so that the menu does not draw with a delay when updating the console. OutputDelay = 0; - // Create variable, that contains key that was pressed. - ConsoleKey keyPressed; + ConsoleKey keyPressed = default; - do + while (keyPressed is not ConsoleKey.Enter) { - // Redraw the menu. Console.Clear(); DisplayMenu(); - - //Read the user's input. - ConsoleKeyInfo keyInfo = Console.ReadKey(); - - // Get the key that was pressed. - keyPressed = keyInfo.Key; - - // Move the selection up or down, based on the pressed key. - if (keyPressed == ConsoleKey.UpArrow) + keyPressed = Console.ReadKey().Key; + if (keyPressed is ConsoleKey.UpArrow) { - SelectedIndex--; - - // Wrap around if user is out of range. - if (SelectedIndex == -1) - { - SelectedIndex = Options.Length - 1; - } + SelectedIndex = SelectedIndex is 0 ? Options.Length - 1 : SelectedIndex - 1; } - else if (keyPressed == ConsoleKey.DownArrow) + else if (keyPressed is ConsoleKey.DownArrow) { - SelectedIndex++; - - // Wrap around if user is out of range. - if (SelectedIndex == Options.Length) - { - SelectedIndex = 0; - } + SelectedIndex = SelectedIndex == Options.Length - 1 ? 0 : SelectedIndex + 1; } - } while (keyPressed != ConsoleKey.Enter); + } - // Return the selected option. return SelectedIndex; } } \ No newline at end of file diff --git a/Projects/Oligopoly/Program.cs b/Projects/Oligopoly/Program.cs index 6407f517..ca2c34ad 100644 --- a/Projects/Oligopoly/Program.cs +++ b/Projects/Oligopoly/Program.cs @@ -12,18 +12,11 @@ public class Program public static List Companies; public static List Events; - /// - /// Program entry point. - /// - /// The array of strings to process. public static void Main() { RunMainMenu(); } - /// - /// Runs the main menu of the game. - /// private static void RunMainMenu() { string prompt = @" @@ -56,9 +49,6 @@ private static void RunMainMenu() } } - /// - /// Runs skip menu. - /// private static void RunSkipMenu() { string prompt = @"Welcome to Oligopoly! @@ -82,9 +72,6 @@ private static void RunSkipMenu() } } - /// - /// Runs the start menu of the game. - /// private static void RunStartMenu() { string prompt = @"Dear, new CEO @@ -102,18 +89,13 @@ The board of directors of Oligopoly Investments int selectedOption = startMenu.RunMenu(); - switch (selectedOption) + if (selectedOption is 0) { - case 0: - Console.Clear(); - RunGameMenu(); - break; + Console.Clear(); + RunGameMenu(); } } - /// - /// Runs the game menu. - /// private static void RunGameMenu() { { @@ -128,22 +110,16 @@ private static void RunGameMenu() } } - // Create variables. - int currentEvent; double money = 10000; bool isGameEnded = false; - - // Create a Random class object to generate event. Random random = new(); // Start of the game cycle. while (!isGameEnded) { - // Generate event for current turn. - currentEvent = random.Next(0, Events.Count); + int currentEvent = random.Next(0, Events.Count); - // Determine current event's type. - if (Events[currentEvent].Type == "Positive") // If current event is positive. + if (Events[currentEvent].Type is "Positive") { foreach (Company currentCompany in Companies) { @@ -153,7 +129,7 @@ private static void RunGameMenu() } } } - else if (Events[currentEvent].Type == "Negative") // If current event is negative. + else if (Events[currentEvent].Type is "Negative") { foreach (Company currentCompany in Companies) { @@ -197,10 +173,6 @@ private static void RunGameMenu() isGameEnded = true; RunEndMenu(true); } - else - { - continue; - } } } @@ -209,7 +181,6 @@ private static void RunGameMenu() /// /// The amount of money that user currently has. /// The index of current generated event. - /// An Data class object, that contain information about companies and events. /// Flag that determines the mode of the method. True - buying, false - selling. private static void RunActionMenu(ref double money, int currentEvent, bool isBuying) { @@ -255,10 +226,6 @@ private static void RunActionMenu(ref double money, int currentEvent, bool isBuy } } - /// - /// Displays companies descriptions to the console. - /// - /// An Data class object, that contain information about companies and events. private static void DisplayMoreAboutCompaniesMenu() { Console.Clear(); @@ -336,9 +303,6 @@ The board of directors of Oligopoly Investments } } - /// - /// Displays information about the game. - /// private static void DisplayAboutInfo() { Console.Clear(); @@ -352,9 +316,6 @@ This game was created by Semion Medvedev (Fuinny) Console.ReadKey(true); } - /// - /// Exits the game. - /// private static void ExitGame() { Console.Clear(); From 724ac0d96d46c8c2ca359af610ab65aa3917f595 Mon Sep 17 00:00:00 2001 From: ZacharyPatten Date: Wed, 10 May 2023 18:12:38 -0500 Subject: [PATCH 10/18] ConsoleColor change to respect players colro settings --- Projects/Oligopoly/GameMenu.cs | 16 ++++------------ Projects/Oligopoly/Menu.cs | 17 ++++------------- 2 files changed, 8 insertions(+), 25 deletions(-) diff --git a/Projects/Oligopoly/GameMenu.cs b/Projects/Oligopoly/GameMenu.cs index d0cddc66..04812ece 100644 --- a/Projects/Oligopoly/GameMenu.cs +++ b/Projects/Oligopoly/GameMenu.cs @@ -61,25 +61,17 @@ protected override void DisplayMenu() for (int i = 0; i < Options.Length; i++) { string currentOption = Options[i]; - string prefix; - if (i == SelectedIndex) { - prefix = "*"; - Console.ForegroundColor = ConsoleColor.Black; - Console.BackgroundColor = ConsoleColor.White; + (Console.BackgroundColor, Console.ForegroundColor) = (Console.ForegroundColor, Console.BackgroundColor); + Console.WriteLine($"[*] {currentOption}"); + Console.ResetColor(); } else { - prefix = " "; - Console.ForegroundColor = ConsoleColor.White; - Console.BackgroundColor = ConsoleColor.Black; + Console.WriteLine($"[ ] {currentOption}"); } - - Console.WriteLine($"[{prefix}] {currentOption}"); } - - Console.ResetColor(); } /// diff --git a/Projects/Oligopoly/Menu.cs b/Projects/Oligopoly/Menu.cs index 1bb138ea..b2daa59e 100644 --- a/Projects/Oligopoly/Menu.cs +++ b/Projects/Oligopoly/Menu.cs @@ -38,24 +38,17 @@ protected virtual void DisplayMenu() for (int i = 0; i < Options.Length; i++) { string currentOption = Options[i]; - string prefix; - if (i == SelectedIndex) { - prefix = "*"; - Console.ForegroundColor = ConsoleColor.Black; - Console.BackgroundColor = ConsoleColor.White; + (Console.BackgroundColor, Console.ForegroundColor) = (Console.ForegroundColor, Console.BackgroundColor); + Console.WriteLine($"[*] {currentOption}"); + Console.ResetColor(); } else { - prefix = " "; - Console.ForegroundColor = ConsoleColor.White; - Console.BackgroundColor = ConsoleColor.Black; + Console.WriteLine($"[ ] {currentOption}"); } - - Console.WriteLine($"[{prefix}] {currentOption}"); } - Console.ResetColor(); } /// @@ -69,7 +62,6 @@ public virtual int RunMenu() OutputDelay = 0; ConsoleKey keyPressed = default; - while (keyPressed is not ConsoleKey.Enter) { Console.Clear(); @@ -84,7 +76,6 @@ public virtual int RunMenu() SelectedIndex = SelectedIndex == Options.Length - 1 ? 0 : SelectedIndex + 1; } } - return SelectedIndex; } } \ No newline at end of file From db2531f673530531901fd6bf07b24709f8744198 Mon Sep 17 00:00:00 2001 From: ZacharyPatten Date: Wed, 10 May 2023 18:17:32 -0500 Subject: [PATCH 11/18] removed "Ticker" from output table as it doesn't seem necessary --- Projects/Oligopoly/GameMenu.cs | 17 ++++++++--------- 1 file changed, 8 insertions(+), 9 deletions(-) diff --git a/Projects/Oligopoly/GameMenu.cs b/Projects/Oligopoly/GameMenu.cs index 04812ece..b1d3cf14 100644 --- a/Projects/Oligopoly/GameMenu.cs +++ b/Projects/Oligopoly/GameMenu.cs @@ -29,19 +29,18 @@ protected override void DisplayMenu() { // column widths const int c0 = 30; - const int c1 = 8; - const int c2 = 10; - const int c3 = 19; - const int c4 = 17; + const int c1 = 10; + const int c2 = 19; + const int c3 = 17; - Console.WriteLine($"╔═{new('═', c0)}═╤═{new('═', c1)}═╤═{new('═', c2)}═╤═{new('═', c3)}═╤═{new('═', c4)}═╗"); - Console.WriteLine($"║ {"Company", -c0} │ {"Ticker", c1} │ {"Industry", c2} │ {"Share Price", c3} │ {"You Have", c4} ║"); - Console.WriteLine($"╟─{new('─', c0)}─┼─{new('─', c1)}─┼─{new('─', c2)}─┼─{new('─', c3)}─┼─{new('─', c4)}─╢"); + Console.WriteLine($"╔═{new('═', c0)}═╤═{new('═', c1)}═╤═{new('═', c2)}═╤═{new('═', c3)}═╗"); + Console.WriteLine($"║ {"Company", -c0} │ {"Industry", c1} │ {"Share Price", c2} │ {"You Have", c3} ║"); + Console.WriteLine($"╟─{new('─', c0)}─┼─{new('─', c1)}─┼─{new('─', c2)}─┼─{new('─', c3)}─╢"); foreach (Company company in Program.Companies) { - Console.WriteLine($"║ {company.Name, -c0} │ {company.Ticker, c1} │ {company.Industry, c2} │ {company.SharePrice, c3} │ {company.ShareAmount, c4} ║"); + Console.WriteLine($"║ {company.Name, -c0} │ {company.Industry, c1} │ {company.SharePrice, c2} │ {company.ShareAmount, c3} ║"); } - Console.WriteLine($"╚═{new('═', c0)}═╧═{new('═', c1)}═╧═{new('═', c2)}═╧═{new('═', c3)}═╧═{new('═', c4)}═╝"); + Console.WriteLine($"╚═{new('═', c0)}═╧═{new('═', c1)}═╧═{new('═', c2)}═╧═{new('═', c3)}═╝"); Console.WriteLine(); Console.WriteLine($"{Program.Events[CurrentEvent].Title}"); From bb58543e2dbf54897c1006e3e6209c7d4a28111d Mon Sep 17 00:00:00 2001 From: ZacharyPatten Date: Wed, 10 May 2023 19:48:57 -0500 Subject: [PATCH 12/18] clean up and "more company info" bug fix --- Projects/Oligopoly/Company.cs | 1 - Projects/Oligopoly/Company.json | 4 - Projects/Oligopoly/Event.cs | 2 +- Projects/Oligopoly/Event.json | 100 +++++----- Projects/Oligopoly/GameMenu.cs | 23 +-- Projects/Oligopoly/Menu.cs | 17 +- Projects/Oligopoly/Program.cs | 312 +++++++++++++++----------------- 7 files changed, 209 insertions(+), 250 deletions(-) diff --git a/Projects/Oligopoly/Company.cs b/Projects/Oligopoly/Company.cs index a19095f9..078eaf67 100644 --- a/Projects/Oligopoly/Company.cs +++ b/Projects/Oligopoly/Company.cs @@ -5,7 +5,6 @@ namespace Oligopoly; public class Company { public string Name { get; set; } - public string Ticker { get; set; } public string Industry { get; set; } public double SharePrice { get; set; } public double ShareAmount { get; set; } diff --git a/Projects/Oligopoly/Company.json b/Projects/Oligopoly/Company.json index 5f170c57..fb987cc2 100644 --- a/Projects/Oligopoly/Company.json +++ b/Projects/Oligopoly/Company.json @@ -1,7 +1,6 @@ [ { "Name": "Bingoo", - "Ticker": "BNG", "Industry": "Web", "SharePrice": 1500, "ShareAmount": 0, @@ -9,7 +8,6 @@ }, { "Name": "Quantum Software", - "Ticker": "QST", "Industry": "Software", "SharePrice": 2000, "ShareAmount": 0, @@ -17,7 +15,6 @@ }, { "Name": "Edison Incorporated", - "Ticker": "EDSN", "Industry": "Energy", "SharePrice": 1000, "ShareAmount": 0, @@ -33,7 +30,6 @@ }, { "Name": "COBRA Security Consulting", - "Ticker": "CSC", "Industry": "Army", "SharePrice": 1200, "ShareAmount": 0, diff --git a/Projects/Oligopoly/Event.cs b/Projects/Oligopoly/Event.cs index 4e83931d..c03acf1a 100644 --- a/Projects/Oligopoly/Event.cs +++ b/Projects/Oligopoly/Event.cs @@ -5,7 +5,7 @@ namespace Oligopoly; public class Event { public int Effect { get; set; } - public string Target { get; set; } + public string CompanyName { get; set; } public string Type { get; set; } public string Title { get; set; } public string Content { get; set; } diff --git a/Projects/Oligopoly/Event.json b/Projects/Oligopoly/Event.json index 1722d7df..273dc6f1 100644 --- a/Projects/Oligopoly/Event.json +++ b/Projects/Oligopoly/Event.json @@ -1,350 +1,350 @@ [ { "Effect": 15, - "Target": "BNG", + "CompanyName": "Bingoo", "Type": "Positive", "Title": "Bingoo announcing their new search engine", "Content": "The company has announced its new search engine that will be more productive and user-friendly than the previous one. The search engine also uses artificial intelligence technology to improve search results and provide personalized recommendations to users. Experts predict that this will increase the value of the company\u2019s shares and attract more customers to its products and services." }, { "Effect": 10, - "Target": "BNG", + "CompanyName": "Bingoo", "Type": "Positive", "Title": "Bingoo announcing their new AI assistant", "Content": "Bingoo has unveiled its latest innovation: Bingy. An AI assistant that can chat, search, and create content for users. Bingy is powered by advanced natural language processing and machine learning technologies that enable it to understand and communicate fluently in multiple languages. Bingy is available as an application that users can install on their computers or phones for easy and convenient access." }, { "Effect": 5, - "Target": "BNG", + "CompanyName": "Bingoo", "Type": "Positive", "Title": "Bingoo introduces new features and improvements for its web services", "Content": "Bingoo has introduced a series of new features and improvements for its web services. The new features include voice search, image recognition, personalized recommendations, smart suggestions, faster loading times, better security and more. The updates apply to Bingoo\u0027s popular web services such as Bingoo Mail, Bingoo Cloud, Bingoo Maps, Bingoo News and others." }, { "Effect": 5, - "Target": "BNG", + "CompanyName": "Bingoo", "Type": "Positive", "Title": "Bingoo creates a special event to attract more web developers", "Content": "The event, called Bingoo Webathon, is a 24-hour online marathon of web development challenges, tutorials, demos and prizes. Bingoo said that the event is designed to showcase its web services and web applications and to inspire and motivate web developers of all levels and backgrounds to join its community and platform. " }, { "Effect": 5, - "Target": "BNG", + "CompanyName": "Bingoo", "Type": "Positive", "Title": "Bingoo wins industry award for innovative web services", "Content": "Bingoo has won an industry award for its innovative and user-friendly web services, including its search engine and web applications. The award recognizes Bingoo\u0027s commitment to providing the best possible user experiences and staying at the forefront of technology trends." }, { "Effect": 15, - "Target": "BNG", + "CompanyName": "Bingoo", "Type": "Negative", "Title": "Bingoo was accused of violating user privacy", "Content": "The company was accused of stealing the personal data of its users and selling it to third parties without their consent. The case is currently under investigation by the authorities, but experts believe that this scandal will harm the company and its reputation. The company may face legal consequences and lose the trust of its users." }, { "Effect": 10, - "Target": "BNG", + "CompanyName": "Bingoo", "Type": "Negative", "Title": "Bingoo\u0027s servers experience a service outage", "Content": "Bingoo\u0027s services have been down for several hours due to a technical issue. Users have been unable to access their accounts, send emails, or use other Bingoo services during this time. The company has released a statement apologizing for the inconvenience and stating that it is working to resolve the issue as soon as possible." }, { "Effect": 5, - "Target": "BNG", + "CompanyName": "Bingoo", "Type": "Negative", "Title": "Bingoo missed out on a lucrative acquisition deal", "Content": "Bingoo was in talks to acquire a promising startup that could have helped the company expand its services and increase its market share. However, the company\u0027s management decided to abandon the deal at the last minute, citing concerns about the startup\u0027s financial health and market potential. This decision was criticized by shareholders and industry experts, who believe that Bingoo missed a valuable opportunity to grow its business and compete with its rivals." }, { "Effect": 5, - "Target": "BNG", + "CompanyName": "Bingoo", "Type": "Negative", "Title": "Bingoo criticized for excessive advertising in its products", "Content": "Bingoo has been heavily criticized by its users for the excessive amount of ads present in its search engine. Many users have complained that the ads are intrusive and negatively affect their experience with the product. This has led to a decrease in user satisfaction and may ultimately lead to a decrease in sales." }, { "Effect": 5, - "Target": "BNG", + "CompanyName": "Bingoo", "Type": "Negative", "Title": "Bingoo terminates partnerships with phone manufacturers", "Content": "Bingoo has announced that it will no longer be partnering with phone manufacturers to pre-install its search engine on their devices. This decision has been met with disappointment from phone manufacturers, as Bingoo\u0027s search engine is a popular choice among users. The move may lead to a decrease in Bingoo\u0027s market share and revenue, as users may choose other search engines instead." }, { "Effect": 15, - "Target": "QST", + "CompanyName": "Quantum Software", "Type": "Positive", "Title": "Quantum Software announces new operating system", "Content": "The company has introduced its new operating system from the Qore OS family at a presentation event. The company claims that the new operating system is more reliable and faster than the competitors\u2019 ones. The new operating system also has new features and functions that enhance the user experience. Experts expect the company\u2019s share price to rise and the new operating system to become popular among users." }, { "Effect": 10, - "Target": "QST", + "CompanyName": "Quantum Software", "Type": "Positive", "Title": "Quantum Software announces update for Quantum Workflow", "Content": "Quantum Software has just announced an exciting new update for its popular software package - Quantum Workflow. This new version is packed with innovative features and improvements that are sure to streamline your workflow and boost productivity. With its user-friendly interface and powerful capabilities, Quantum Workflow has already become a favorite among professionals in a variety of industries." }, { "Effect": 5, - "Target": "QST", + "CompanyName": "Quantum Software", "Type": "Positive", "Title": "Quantum Software presents its new development kit", "Content": "The company has inoduced its new update for software development kit (QSDK). The new QSDK includes a powerful quantum simulator, a comprehensive set of libraries and frameworks, and a user-friendly development environment that makes it easy to get started with quantum programming. With QSDK developers also have access to new documnetation (QSDN), which will help them build robust and scalable applications." }, { "Effect": 5, - "Target": "QST", + "CompanyName": "Quantum Software", "Type": "Positive", "Title": "Quantum Software acquires a promising company", "Content": "Quantum Software management has confirmed the purchase of a small software company. According to the company\u0027s management, the deal turned out to be very beneficial for both parties. The new software will soon be available on Quore OS operating systems and the company expects sales to increase in the near future." }, { "Effect": 5, - "Target": "QST", + "CompanyName": "Quantum Software", "Type": "Positive", "Title": "Quantum Software invests in Quantum Sky development", "Content": "Quantum Software announced a major investment in the development of Quantum Sky, its cloud platform and infrastructure for creating innovative solutions in artificial intelligence, big data and internet of things. Quantum Sky aims to provide customers with access to the most advanced quantum computing resources and services, as well as to foster collaboration and innovation among researchers, developers and entrepreneurs. Quantum Software expects that Quantum Sky will boost its revenue and market share" }, { "Effect": 15, - "Target": "QST", + "CompanyName": "Quantum Software", "Type": "Negative", "Title": "The Antimonopoly Commission accused Quantum Software of illegally maintaining its monopoly position", "Content": "The Antimonopoly Commission announced that it has launched an investigation into Quantum Software. The commission claims that Quantum Software has abused its dominant position by engaging in unfair practices such as predatory pricing, exclusive contracts, and bundling products. The commission said that these practices have harmed consumers and competitors, and stifled innovation in the software market. The company said that it operates in a highly competitive and dynamic environment, and that its success is based on its superior products and services." }, { "Effect": 10, - "Target": "QST", + "CompanyName": "Quantum Software", "Type": "Negative", "Title": "Quantum Software reported a data breach", "Content": "Some of the company\u2019s servers were hacked by unknown attackers. The company is working with the police on this matter, but it is already known that their development of an unreleased operating system was stolen. The stolen data may contain sensitive information and secrets that could damage the company\u2019s business. The company may also face legal action from its partners and customers who were affected by the breach." }, { "Effect": 5, - "Target": "QST", + "CompanyName": "Quantum Software", "Type": "Negative", "Title": "Users are unhappy with the latest Quore OS update", "Content": "The latest update of Quore OS leads to numerous system breakdowns, and in some cases, loss of user data. Quantum Software has already apologized for the inconvenience and is working to remedy the situation. However, this event has caused many to consider alternative products, which could lead to a decrease in sales of Quantum Software." }, { "Effect": 5, - "Target": "QST", + "CompanyName": "Quantum Software", "Type": "Negative", "Title": "Quantum Software breaks partnership with driver manufacturer", "Content": "Quantum Software management announced the termination of cooperation with one of the largest manufacturers of drivers for their systems. The reasons for this abrupt decision are not clear. The company said it is looking into alternative solutions to this problem. However, this may cause their operating systems to fall behind technically and reduce profits." }, { "Effect": 5, - "Target": "QST", + "CompanyName": "Quantum Software", "Type": "Negative", "Title": "Quantum Software faced mass layoffs", "Content": "The company is facing massive layoffs. Employees say that before the release of the next major update, management began to set impossible tasks for them and give them the shortest possible time. The company\u0027s management has not yet commented on this, but this news will definitely not benefit the company\u0027s share prices." }, { "Effect": 15, - "Target": "EDSN", + "CompanyName": "Edison Incorporated", "Type": "Positive", "Title": "Edison Incorporated presents its new electric car", "Content": "The company\u2019s new electric cars with autopilot function went on sale in several countries. Edison Incorporated has managed to reduce the charging time of the car and increase its battery life by using innovative technology and materials. The first owners of electric cars are already leaving positive reviews and praising the performance and design of the car. The company expects to increase its sales and market share in the electric vehicle industry." }, { "Effect": 10, - "Target": "EDSN", + "CompanyName": "Edison Incorporated", "Type": "Positive", "Title": "Edison Incorporated enters the Asian market", "Content": "The company has announced that it will start selling its electric vehicles in several Asian countries, including China, Japan, and India. The company said that it sees a huge potential for growth in these markets, as the demand for green and smart transportation is increasing. Edison Incorporated expects that this move will boost its sales and revenue, as well as its brand recognition and reputation." }, { "Effect": 5, - "Target": "EDSN", + "CompanyName": "Edison Incorporated", "Type": "Positive", "Title": "Edison Incorporated launches a successful advertising campaign", "Content": "The company has launched a new advertising campaign to promote its electric vehicles and solar panels. The campaign features celebrities, influencers, and ordinary people who share their positive experiences with the company\u2019s products and services. The campaign also highlights the environmental and economic benefits of switching to renewable energy sources. The campaign has received a lot of positive feedback and attention from the public and the media, and has increased the company\u2019s popularity and customer loyalty." }, { "Effect": 5, - "Target": "EDSN", + "CompanyName": "Edison Incorporated", "Type": "Positive", "Title": "Edison Incorporated develops a more efficient electric engine", "Content": "Edison Incorporated has developed a new electric engine that is more efficient and powerful than its previous models. The new engine uses less energy and produces less noise and emissions. The company said that the new engine will improve the performance and range of its electric vehicles, as well as reduce the maintenance costs and carbon footprint. The company plans to implement the new engine in its upcoming models and offer it as an upgrade option for existing customers. " }, { "Effect": 5, - "Target": "EDSN", + "CompanyName": "Edison Incorporated", "Type": "Positive", "Title": "Edison Incorporated reduces the prices of its products", "Content": "The company has announced that it will reduce the prices of its electric vehicles and solar panels by 10%. Edison Incorporated said that this decision is motivated by its desire to make its products more affordable and accessible to a wider range of customers. The company also said that it has achieved significant cost reductions thanks to its technological innovations and economies of scale. The price reduction is expected to increase the demand and sales of the company\u2019s products, as well as its market share and competitiveness." }, { "Effect": 15, - "Target": "EDSN", + "CompanyName": "Edison Incorporated", "Type": "Negative", "Title": "Edison Incorporated is facing production difficulties", "Content": "The company said it was having difficulty mining lithium, which is a key material for producing batteries for electric vehicles. The company blamed the shortage of lithium on environmental issues and political instability in some regions. Edison Incorporated assures that the difficulties are temporary and that it is looking for alternative sources of lithium. But we can already say that they harmed the company\u2019s production and profits." }, { "Effect": 10, - "Target": "EDSN", + "CompanyName": "Edison Incorporated", "Type": "Negative", "Title": "Edison Incorporated recalls some of its electric vehicles ", "Content": "Edison Incorporated has announced that it will recall some of its electric vehicles due to a defect in the battery system that could cause overheating and fire. The company said that the recall affects a small percentage of its vehicles and that it will provide free repairs and replacements to the affected customers. The company apologized for the inconvenience and said that it is taking all the necessary measures to ensure the safety and quality of its products. However, this incident has damaged the company\u2019s reputation and customer confidence." }, { "Effect": 5, - "Target": "EDSN", + "CompanyName": "Edison Incorporated", "Type": "Negative", "Title": "Edison Incorporated faces increased competition in the electric vehicle market", "Content": "The company faces increased competition from other companies that are also producing and selling electric vehicles. Some of these competitors offer similar or better products at lower prices or with more features and options. The company said that it is confident in its products and services and that it will continue to innovate and improve its offerings. However, this may affect the company\u2019s sales and market share, as customers may choose other alternatives. " }, { "Effect": 5, - "Target": "EDSN", + "CompanyName": "Edison Incorporated", "Type": "Negative", "Title": "Customers criticize Edison Incorporated", "Content": "The company has received some criticism from its customers who are unhappy with some aspects of its products and services. The customers have complained about the high prices, long delivery times, and poor customer service of the company. The company has responded to the criticism by acknowledging the issues and promising to improve its performance and quality. Edison Incorporated said that it values its customers\u2019 feedback and that it will use it to enhance its products and services. The company hopes that this will restore its customer trust and satisfaction." }, { "Effect": 5, - "Target": "EDSN", + "CompanyName": "Edison Incorporated", "Type": "Negative", "Title": "Edison Incorporated reports problems with its autopilot system", "Content": "The company has reported that some of its electric vehicles have experienced problems with their autopilot system. The system is supposed to assist the driver in steering, braking, and changing lanes, but some customers have reported that it has malfunctioned or failed to respond in some situations. Edison Incorporated said that it is investigating the cause of the problems and that it will issue a software update to fix them. The company also advised its customers to always pay attention and be ready to take over the control of the vehicle when using the autopilot system. The problems have raised some safety and reliability concerns among the customers and the regulators." }, { "Effect": 15, - "Target": "NTF", + "CompanyName": "Netfilm", "Type": "Positive", "Title": "Netfilm announces new series", "Content": "The company has confirmed the creation of its new series, which will be exclusive to its platform. The title and plot are still unknown, but the public already looks interested and curious. The company said that the new series will be a high-quality production with a talented cast and crew. The company hopes that the new series will attract more subscribers and viewers to its platform." }, { "Effect": 10, - "Target": "NTF", + "CompanyName": "Netfilm", "Type": "Positive", "Title": "Netfilm wins awards for its original content", "Content": "The company has won several awards for its original content, including movies and series. The awards recognize Netfilm\u2019s creativity and excellence in producing and streaming high-quality content that appeals to a wide audience. The awards also boost Netfilm\u2019s reputation and popularity in the online streaming industry." }, { "Effect": 5, - "Target": "NTF", + "CompanyName": "Netfilm", "Type": "Positive", "Title": "Netfilm improves its video hosting service", "Content": "Netfilm has announced that it has improved its video hosting service, which allows users to upload and stream their own videos on its platform. The company said that the improvement will enhance the quality, speed, and security of the video hosting service, as well as provide more options and features for users. The company said that the improvement will attract more users and creators to its platform, and increase its revenue and profit." }, { "Effect": 5, - "Target": "NTF", + "CompanyName": "Netfilm", "Type": "Positive", "Title": "Netfilm offers a subscription discount", "Content": "Netfilm has announced that it will offer a subscription discount for its customers who sign up for a year or more. The company said that the discount will make its service more affordable and accessible for its customers, as well as increase its customer loyalty and retention. The company said that the discount is part of its customer appreciation and promotion campaign." }, { "Effect": 5, - "Target": "NTF", + "CompanyName": "Netfilm", "Type": "Positive", "Title": "Netfilm rewards its loyal customers", "Content": "Netfilm has announced that it has rewarded its loyal customers with special offers and benefits. The company said that it has launched a loyalty program that allows its customers to earn points and redeem them for discounts, free trials, or exclusive content. The company also said that it has sent personalized recommendations and gifts to its customers, based on their preferences and interests." }, { "Effect": 15, - "Target": "NTF", + "CompanyName": "Netfilm", "Type": "Negative", "Title": "Netfilm faced lawsuit", "Content": "Netfilm sued by movie studios for streaming their content without permission. Netfilm denies the charges and says it has a fair use policy that allows it to stream content for educational and entertainment purposes. The lawsuit could affect the online streaming industry and set a precedent for future cases. The company may have to pay a large amount of money in damages or remove some content from its platform." }, { "Effect": 10, - "Target": "NTF", + "CompanyName": "Netfilm", "Type": "Negative", "Title": "Netfilm delays new releases", "Content": "Netfilm has announced that it will delay some of its new releases, due to production difficulties or quality issues. The company said that it wants to ensure that its new releases meet its high standards and expectations, and that it apologizes for any inconvenience caused to its customers. However, this decision has disappointed some of its customers who were eagerly waiting for the new releases, and has given an advantage to its competitors who have released their content on time." }, { "Effect": 5, - "Target": "NTF", + "CompanyName": "Netfilm", "Type": "Negative", "Title": "Netfilm faces controversy over its content", "Content": "Netfilm has faced controversy over some of its content, which has been accused of being offensive, inappropriate, or inaccurate. Some of its content has sparked backlash and criticism from various groups and individuals, who have demanded that Netfilm remove or apologize for the content. Some of its content has also been banned or censored in some countries or regions, due to legal or cultural reasons. This controversy has harmed Netfilm\u2019s image and reputation, as well as caused some of its customers and partners to boycott or cancel its service." }, { "Effect": 5, - "Target": "NTF", + "CompanyName": "Netfilm", "Type": "Negative", "Title": "Netfilm faces piracy threat", "Content": "Netfilm has faced piracy threat, which has affected its revenue and profit. The company has discovered that some of its content has been illegally copied or distributed by unauthorized parties or platforms. The company has also found that some of its customers have shared their accounts or passwords with others, who have accessed its service without paying. The company said that it is taking measures to protect its intellectual property rights and to prevent piracy. However, this situation has reduced Netfilm\u2019s income and market share, as well as damaged its exclusivity and value." }, { "Effect": 5, - "Target": "NTF", + "CompanyName": "Netfilm", "Type": "Negative", "Title": "Netfilm faces employee strike", "Content": "Netfilm has faced employee strike, which has disrupted its operations and productivity. The company\u2019s employees have gone on strike to demand better working conditions, wages, and benefits. The company said that it is negotiating with the employees and their representatives, and that it hopes to reach a fair and reasonable agreement. However, this situation has affected Netfilm\u2019s performance and output, as well as its relationship and trust with its employees." }, { "Effect": 15, - "Target": "CSC", + "CompanyName": "COBRA Security Consulting", "Type": "Positive", "Title": "COBRA Security Consulting signs a contract with the government", "Content": "The company signed a contract with the government to ensure the security of state facilities such as military bases, power plants, airports, etc. COBRA operatives are already arriving at the facilities and setting up security measures. The exact amount of the contract was not disclosed, but it is already clear that the contract is beneficial to both parties. The contract will provide a stable income for the company and enhance the security of the state facilities." }, { "Effect": 10, - "Target": "CSC", + "CompanyName": "COBRA Security Consulting", "Type": "Positive", "Title": "The United Nations gives permission for COBRA Security Consulting to operate in new territories", "Content": "The United Nations has granted permission for COBRA Security Consulting to operate in new territories that are under its supervision and protection. The permission allows the company to provide security services and solutions to various clients and sectors in these territories, such as humanitarian organizations, businesses, and governments. The company said that the permission is a sign of its credibility and reputation, as well as an opportunity to expand its scope and impact." }, { "Effect": 5, - "Target": "CSC", + "CompanyName": "COBRA Security Consulting", "Type": "Positive", "Title": "COBRA Security Consulting successfully completes the rescue operation", "Content": "COBRA Security Consulting announced that it has successfully completed the rescue operation of a group of hostages held by a terrorist organization in a remote location. The operation involved a team of highly trained and experienced operatives who infiltrated the enemy camp and freed the hostages without any casualties. The hostages were then transported to a safe place and reunited with their families. The company said that the operation was a testament to its skills and dedication to saving lives." }, { "Effect": 5, - "Target": "CSC", + "CompanyName": "COBRA Security Consulting", "Type": "Positive", "Title": "COBRA Security Consulting unveils its new technology and equipment", "Content": "COBRA Security Consulting unveils its new technology and equipment for its operatives. The new technology and equipment include advanced drones, sensors, weapons, and communication devices that enhance the capabilities and safety of its operatives. The company said that the new technology and equipment will give it an edge over its competitors and adversaries" }, { "Effect": 5, - "Target": "CSC", + "CompanyName": "COBRA Security Consulting", "Type": "Positive", "Title": "COBRA Security Consulting secures a supply contract with government", "Content": "COBRA Security Consulting revealed that it has provided security supplies to the government as part of a contract to equip its forces and agencies with the latest security equipment and technology. The contract will enhance the company\u2019s revenue and reputation, as well as show its competence and dependability of its products and services. The company said that the contract is an acknowledgment of its innovation and excellence, and that it is pleased and honored to collaborate with the government." }, { "Effect": 15, - "Target": "CSC", + "CompanyName": "COBRA Security Consulting", "Type": "Negative", "Title": "COBRA Security Consulting is being criticized for their violent actions", "Content": "COBRA Security Consulting has been criticized for its harsh actions in the Middle East on the territory of the facilities under its protection. The company\u2019s management states that this is necessary to ensure security in the region and prevent terrorist attacks. However, some human rights organizations and media outlets accuse the company of using excessive force and violating international law. Government has already become interested in this case, and most likely the company will face punishment such as sanctions, fines, or termination of contracts." }, { "Effect": 10, - "Target": "CSC", + "CompanyName": "COBRA Security Consulting", "Type": "Negative", "Title": "COBRA Security Consulting brigades were captured", "Content": "COBRA Security Consulting confirmed that some of its brigades were captured by a rebel group during a security operation. The brigades were part of a team that was providing security and escort to a convoy of humanitarian aid workers who were delivering supplies to a war-torn area. The rebel group ambushed the convoy and took the brigades as hostages. The company said that it is in contact with the rebel group and is negotiating for the release of the brigades. The company also said that it is doing everything in its power to ensure the safety and well-being of its brigades." }, { "Effect": 5, - "Target": "CSC", + "CompanyName": "COBRA Security Consulting", "Type": "Negative", "Title": "Fighter of COBRA Security Consulting was shot down", "Content": "COBRA Security Consulting confirmed that one of its fighters was shot down by an unknown enemy during a security mission. The fighter was part of a team that was providing air support to a client who was under attack by a hostile force. The fighter was hit by a missile and crashed in a remote area. The company said that it is trying to locate and rescue the pilot, who is presumed to be alive. The company also said that it is investigating the identity and motive of the enemy who shot down the fighter." }, { "Effect": 5, - "Target": "CSC", + "CompanyName": "COBRA Security Consulting", "Type": "Negative", "Title": "COBRA Security Consulting vehicle involved in a deadly accident", "Content": "A COBRA Security Consulting vehicle has been involved in a serious accident that resulted in several casualties, including civilians and company personnel. The accident happened during a convoy operation, and the cause of the accident is still under investigation. The company is offering support and compensation to the victims and their families, but it may face legal action and reputational damage from the incident." }, { "Effect": 5, - "Target": "CSC", + "CompanyName": "COBRA Security Consulting", "Type": "Negative", "Title": "COBRA Security Consulting staff arrested for illegal activity", "Content": "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." diff --git a/Projects/Oligopoly/GameMenu.cs b/Projects/Oligopoly/GameMenu.cs index b1d3cf14..88d2125b 100644 --- a/Projects/Oligopoly/GameMenu.cs +++ b/Projects/Oligopoly/GameMenu.cs @@ -1,5 +1,4 @@ using System; -using System.Threading; namespace Oligopoly; @@ -15,8 +14,8 @@ public class GameMenu : Menu /// The options to display in the menu. /// The text output delay. Have to be a positive integer or zero. /// The integer that represents current event. - public GameMenu(string prompt, string[] options, int outputDelay, int currentEvent, double money) - : base(prompt, options, outputDelay) + public GameMenu(string prompt, string[] options, int currentEvent, double money) + : base(prompt, options) { CurrentEvent = currentEvent; Money = money; @@ -49,13 +48,9 @@ protected override void DisplayMenu() Console.WriteLine(); Console.WriteLine($"You have: {Math.Round(Money, 2)}$"); - //Console.WriteLine(); + Console.WriteLine(); - foreach (char symbol in Prompt) - { - Thread.Sleep(OutputDelay); - Console.Write(symbol); - } + Console.WriteLine(Prompt); for (int i = 0; i < Options.Length; i++) { @@ -79,15 +74,12 @@ protected override void DisplayMenu() /// An integer that represents the selected option. public override int RunMenu() { - // Set output delay to 0. - // This is necessary so that the menu does not draw with a delay when updating the console. - OutputDelay = 0; - ConsoleKey keyPressed = default; while (keyPressed is not ConsoleKey.Enter) { Console.Clear(); DisplayMenu(); + Console.CursorVisible = false; keyPressed = Console.ReadKey().Key; if (keyPressed is ConsoleKey.UpArrow) { @@ -108,10 +100,6 @@ public override int RunMenu() /// An integer, that represents the amount of shares. public int RunAmountMenu() { - // Set output delay to 0. - // This is necessary so that the menu does not draw with a delay when updating the console. - OutputDelay = 0; - ConsoleKey keyPressed = default; int amount = 0; while (keyPressed is not ConsoleKey.Enter || SelectedIndex is not 2) @@ -119,6 +107,7 @@ public int RunAmountMenu() Console.Clear(); DisplayMenu(); Console.WriteLine($"Current amount: {amount}"); + Console.CursorVisible = false; keyPressed = Console.ReadKey().Key; switch (keyPressed) { diff --git a/Projects/Oligopoly/Menu.cs b/Projects/Oligopoly/Menu.cs index b2daa59e..46239f97 100644 --- a/Projects/Oligopoly/Menu.cs +++ b/Projects/Oligopoly/Menu.cs @@ -1,12 +1,10 @@ using System; -using System.Threading; namespace Oligopoly; public class Menu { protected int SelectedIndex; - protected int OutputDelay; protected string Prompt; protected string[] Options; @@ -16,11 +14,10 @@ public class Menu /// The prompt to display above the menu. /// The options to display in the menu. /// The text output delay. Have to be a positive integer or zero! - public Menu(string prompt, string[] options, int outputDelay) + public Menu(string prompt, string[] options) { Prompt = prompt; Options = options; - OutputDelay = outputDelay; SelectedIndex = 0; } @@ -29,12 +26,7 @@ public Menu(string prompt, string[] options, int outputDelay) /// protected virtual void DisplayMenu() { - foreach (char symbol in Prompt) - { - Thread.Sleep(OutputDelay); - Console.Write(symbol); - } - + Console.WriteLine(Prompt); for (int i = 0; i < Options.Length; i++) { string currentOption = Options[i]; @@ -57,15 +49,12 @@ protected virtual void DisplayMenu() /// An integer that represents the selected option. public virtual int RunMenu() { - // Set output delay to 0. - // This is necessary so that the menu does not draw with a delay when updating the console. - OutputDelay = 0; - ConsoleKey keyPressed = default; while (keyPressed is not ConsoleKey.Enter) { Console.Clear(); DisplayMenu(); + Console.CursorVisible = false; keyPressed = Console.ReadKey().Key; if (keyPressed is ConsoleKey.UpArrow) { diff --git a/Projects/Oligopoly/Program.cs b/Projects/Oligopoly/Program.cs index ca2c34ad..c7148504 100644 --- a/Projects/Oligopoly/Program.cs +++ b/Projects/Oligopoly/Program.cs @@ -3,18 +3,40 @@ using System.IO; using System.Reflection; using System.Text.Json; -using System.Threading; namespace Oligopoly; public class Program { - public static List Companies; - public static List Events; + public static bool CloseRequested { get; set; } = false; + public static List Companies { get; private set; } = null!; + public static List Events { get; private set; } = null!; public static void Main() { - RunMainMenu(); + try + { + Console.CursorVisible = false; + LoadEmbeddedResources(); + RunMainMenu(); + } + finally + { + Console.CursorVisible = true; + } + } + + public static void LoadEmbeddedResources() + { + Assembly assembly = Assembly.GetExecutingAssembly(); + { + using Stream? stream = assembly.GetManifestResourceStream("Oligopoly.Company.json"); + Companies = JsonSerializer.Deserialize>(stream!)!; + } + { + using Stream? stream = assembly.GetManifestResourceStream("Oligopoly.Event.json"); + Events = JsonSerializer.Deserialize>(stream!)!; + } } private static void RunMainMenu() @@ -30,86 +52,61 @@ private static void RunMainMenu() "; string[] options = { "Play", "About", "Exit" }; - Menu mainMenu = new(prompt, options, 0); - - int selectedOption = mainMenu.RunMenu(); + Menu mainMenu = new(prompt, options); - switch (selectedOption) + while (!CloseRequested) { - case 0: - RunSkipMenu(); - break; - case 1: - DisplayAboutInfo(); - RunMainMenu(); - break; - case 2: - ExitGame(); - break; - } - } - - private static void RunSkipMenu() - { - string prompt = @"Welcome to Oligopoly! -Do you want to read the introductory letter or do you want to jump right into the gameplay? - -"; - string[] options = { "Read introductory letter", "Skip introductory letter" }; - - Menu skipMenu = new(prompt, options, 0); - - int selectedOption = skipMenu.RunMenu(); - - switch (selectedOption) - { - case 0: - RunStartMenu(); - break; - case 1: - RunGameMenu(); - break; + int selectedOption = mainMenu.RunMenu(); + switch (selectedOption) + { + case 0: + RunStartMenu(); + break; + case 1: + DisplayAboutInfo(); + break; + case 2: + CloseRequested = true; + break; + } } + Console.Clear(); + Console.WriteLine("Press any key to exit the game..."); + Console.CursorVisible = false; + Console.ReadKey(true); } private static void RunStartMenu() { - string prompt = @"Dear, new CEO - 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 - -"; - string[] options = { "Get Access" }; - - Menu startMenu = new(prompt, options, 15); - - int selectedOption = startMenu.RunMenu(); - - if (selectedOption is 0) - { - Console.Clear(); - RunGameMenu(); - } + 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("Press any key to continue..."); + Console.CursorVisible = false; + Console.ReadKey(true); + RunGameMenu(); } private static void RunGameMenu() { - { - Assembly assembly = Assembly.GetExecutingAssembly(); - { - using Stream? stream = assembly.GetManifestResourceStream("Oligopoly.Company.json"); - Companies = JsonSerializer.Deserialize>(stream!)!; - } - { - using Stream? stream = assembly.GetManifestResourceStream("Oligopoly.Event.json"); - Events = JsonSerializer.Deserialize>(stream!)!; - } - } - double money = 10000; bool isGameEnded = false; Random random = new(); @@ -123,7 +120,7 @@ private static void RunGameMenu() { foreach (Company currentCompany in Companies) { - if (currentCompany.Ticker == Events[currentEvent].Target) + if (currentCompany.Name == Events[currentEvent].CompanyName) { currentCompany.SharePrice = Math.Round(currentCompany.SharePrice + currentCompany.SharePrice * Events[currentEvent].Effect / 100, 2); } @@ -133,33 +130,33 @@ private static void RunGameMenu() { foreach (Company currentCompany in Companies) { - if (currentCompany.Ticker == Events[currentEvent].Target) + if (currentCompany.Name == Events[currentEvent].CompanyName) { currentCompany.SharePrice = Math.Round(currentCompany.SharePrice - currentCompany.SharePrice * Events[currentEvent].Effect / 100, 2); } } } - string prompt = "\nUse up and down arrow keys to select an option: \n"; + string prompt = "Use up and down arrow keys to select an option:"; string[] options = { "Skip", "Buy", "Sell", "More About Companies" }; - GameMenu gameMenu = new(prompt, options, 0, currentEvent, money); - - int selectedOption = gameMenu.RunMenu(); + GameMenu gameMenu = new(prompt, options, currentEvent, money); - switch (selectedOption) + int selectedOption = -1; + while (selectedOption is not 0) { - case 0: - break; - case 1: - RunActionMenu(ref money, currentEvent, true); - break; - case 2: - RunActionMenu(ref money, currentEvent, false); - break; - case 3: - DisplayMoreAboutCompaniesMenu(); - gameMenu.RunMenu(); - break; + selectedOption = gameMenu.RunMenu(); + switch (selectedOption) + { + case 1: + RunActionMenu(ref money, currentEvent, true); + break; + case 2: + RunActionMenu(ref money, currentEvent, false); + break; + case 3: + DisplayMoreAboutCompaniesMenu(); + break; + } } // Check for win or loss. @@ -194,8 +191,8 @@ private static void RunActionMenu(ref double money, int currentEvent, bool isBuy actionOptions[i] = Companies[i].Name; } - GameMenu actionMenu = new(actionPrompt, actionOptions, 0, currentEvent, money); - GameMenu amountMenu = new(amountPrompt, amountOptions, 0, currentEvent, money); + GameMenu actionMenu = new(actionPrompt, actionOptions, currentEvent, money); + GameMenu amountMenu = new(amountPrompt, amountOptions, currentEvent, money); int selectedCompany = actionMenu.RunMenu(); int amountOfShares = amountMenu.RunAmountMenu(); @@ -206,7 +203,9 @@ private static void RunActionMenu(ref double money, int currentEvent, bool isBuy money -= amountOfShares * Companies[selectedCompany].SharePrice; Console.WriteLine($"You have bought {amountOfShares} shares of {Companies[selectedCompany].Name} company."); - Thread.Sleep(2500); + Console.WriteLine("Press any key to continue..."); + Console.CursorVisible = false; + Console.ReadKey(true); } else { @@ -216,12 +215,16 @@ private static void RunActionMenu(ref double money, int currentEvent, bool isBuy money += amountOfShares * Companies[selectedCompany].SharePrice; Console.WriteLine($"You have sold {amountOfShares} shares of {Companies[selectedCompany].Name} company."); - Thread.Sleep(2500); + Console.WriteLine("Press any key to continue..."); + Console.CursorVisible = false; + Console.ReadKey(true); } else { Console.WriteLine("Entered not a valid value"); - Thread.Sleep(2500); + Console.WriteLine("Press any key to continue..."); + Console.CursorVisible = false; + Console.ReadKey(true); } } } @@ -229,13 +232,12 @@ private static void RunActionMenu(ref double money, int currentEvent, bool isBuy private static void DisplayMoreAboutCompaniesMenu() { Console.Clear(); - foreach (Company company in Companies) { Console.WriteLine($"{company.Name} - {company.Description}\n"); } - Console.WriteLine("Press any key to exit the menu..."); + Console.CursorVisible = false; Console.ReadKey(true); } @@ -246,81 +248,65 @@ private static void DisplayMoreAboutCompaniesMenu() private static void RunEndMenu(bool isWinner) { Console.Clear(); - if (isWinner) { - string prompt = @"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 - -"; - string[] options = { "Play Again", "Return to Main Menu" }; - - Menu EndMenu = new(prompt, options, 15); - - int selectedOption = EndMenu.RunMenu(); - - switch (selectedOption) - { - case 0: - RunGameMenu(); - break; - case 1: - RunMainMenu(); - break; - } + 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("Press any key to continue..."); + Console.CursorVisible = false; + Console.ReadKey(true); } else { - string prompt = @"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 - -"; - string[] options = { "Play Again", "Return to Main Menu" }; - - Menu EndMenu = new(prompt, options, 15); - - int selectedOption = EndMenu.RunMenu(); - - switch (selectedOption) - { - case 0: - RunGameMenu(); - break; - case 1: - RunMainMenu(); - break; - } + 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("Press any key to continue..."); + Console.CursorVisible = false; + Console.ReadKey(true); } } private static void DisplayAboutInfo() { Console.Clear(); - Console.WriteLine(@"THANKS! -No really, thank you for taking time to play this simple console game. It means a lot. - -This game was created by Semion Medvedev (Fuinny) -My GitHub profile: https://github.com/Fuinny - -Press any key to exit the menu..."); - Console.ReadKey(true); - } - - private static void ExitGame() - { - Console.Clear(); - Console.WriteLine("Press any key to exit the game..."); + 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("Press any key to continue..."); + Console.CursorVisible = false; Console.ReadKey(true); - Environment.Exit(0); } } \ No newline at end of file From aca5043de7c61f72560e22922adafd691e16bc28 Mon Sep 17 00:00:00 2001 From: ZacharyPatten Date: Wed, 10 May 2023 20:23:10 -0500 Subject: [PATCH 13/18] escape key to close game --- Projects/Oligopoly/GameMenu.cs | 23 +++++++++----- Projects/Oligopoly/Menu.cs | 18 ++++++----- Projects/Oligopoly/Program.cs | 56 +++++++++++++++++++--------------- 3 files changed, 58 insertions(+), 39 deletions(-) diff --git a/Projects/Oligopoly/GameMenu.cs b/Projects/Oligopoly/GameMenu.cs index 88d2125b..af52e85d 100644 --- a/Projects/Oligopoly/GameMenu.cs +++ b/Projects/Oligopoly/GameMenu.cs @@ -75,19 +75,23 @@ protected override void DisplayMenu() public override int RunMenu() { ConsoleKey keyPressed = default; - while (keyPressed is not ConsoleKey.Enter) + while (!Program.CloseRequested && keyPressed is not ConsoleKey.Enter) { Console.Clear(); DisplayMenu(); Console.CursorVisible = false; keyPressed = Console.ReadKey().Key; - if (keyPressed is ConsoleKey.UpArrow) - { - SelectedIndex = SelectedIndex is 0 ? Options.Length - 1 : SelectedIndex - 1; - } - else if (keyPressed is ConsoleKey.DownArrow) + switch (keyPressed) { - SelectedIndex = SelectedIndex == Options.Length - 1 ? 0 : SelectedIndex + 1; + case ConsoleKey.UpArrow: + SelectedIndex = SelectedIndex is 0 ? Options.Length - 1 : SelectedIndex - 1; + break; + case ConsoleKey.DownArrow: + SelectedIndex = SelectedIndex == Options.Length - 1 ? 0 : SelectedIndex + 1; + break; + case ConsoleKey.Escape: + Program.CloseRequested = true; + break; } } @@ -102,7 +106,7 @@ public int RunAmountMenu() { ConsoleKey keyPressed = default; int amount = 0; - while (keyPressed is not ConsoleKey.Enter || SelectedIndex is not 2) + while (!Program.CloseRequested && (keyPressed is not ConsoleKey.Enter || SelectedIndex is not 2)) { Console.Clear(); DisplayMenu(); @@ -127,6 +131,9 @@ public int RunAmountMenu() amount--; } break; + case ConsoleKey.Escape: + Program.CloseRequested = true; + break; } } diff --git a/Projects/Oligopoly/Menu.cs b/Projects/Oligopoly/Menu.cs index 46239f97..f59bf6c6 100644 --- a/Projects/Oligopoly/Menu.cs +++ b/Projects/Oligopoly/Menu.cs @@ -50,19 +50,23 @@ protected virtual void DisplayMenu() public virtual int RunMenu() { ConsoleKey keyPressed = default; - while (keyPressed is not ConsoleKey.Enter) + while (!Program.CloseRequested && keyPressed is not ConsoleKey.Enter) { Console.Clear(); DisplayMenu(); Console.CursorVisible = false; keyPressed = Console.ReadKey().Key; - if (keyPressed is ConsoleKey.UpArrow) + switch (keyPressed) { - SelectedIndex = SelectedIndex is 0 ? Options.Length - 1 : SelectedIndex - 1; - } - else if (keyPressed is ConsoleKey.DownArrow) - { - SelectedIndex = SelectedIndex == Options.Length - 1 ? 0 : SelectedIndex + 1; + case ConsoleKey.UpArrow: + SelectedIndex = SelectedIndex is 0 ? Options.Length - 1 : SelectedIndex - 1; + break; + case ConsoleKey.DownArrow: + SelectedIndex = SelectedIndex == Options.Length - 1 ? 0 : SelectedIndex + 1; + break; + case ConsoleKey.Escape: + Program.CloseRequested = true; + break; } } return SelectedIndex; diff --git a/Projects/Oligopoly/Program.cs b/Projects/Oligopoly/Program.cs index c7148504..165fa44b 100644 --- a/Projects/Oligopoly/Program.cs +++ b/Projects/Oligopoly/Program.cs @@ -2,6 +2,7 @@ using System.Collections.Generic; using System.IO; using System.Reflection; +using System.Text; using System.Text.Json; namespace Oligopoly; @@ -41,18 +42,25 @@ public static void LoadEmbeddedResources() private static void RunMainMenu() { - string prompt = @" - ██████╗ ██╗ ██╗ ██████╗ ██████╗ ██████╗ ██████╗ ██╗ ██╗ ██╗ -██╔═══██╗██║ ██║██╔════╝ ██╔═══██╗██╔══██╗██╔═══██╗██║ ╚██╗ ██╔╝ -██║ ██║██║ ██║██║ ███╗██║ ██║██████╔╝██║ ██║██║ ╚████╔╝ -██║ ██║██║ ██║██║ ██║██║ ██║██╔═══╝ ██║ ██║██║ ╚██╔╝ -╚██████╔╝███████╗██║╚██████╔╝╚██████╔╝██║ ╚██████╔╝███████╗██║ - ╚═════╝ ╚══════╝╚═╝ ╚═════╝ ╚═════╝ ╚═╝ ╚═════╝ ╚══════╝╚═╝ - --Use up and down arrow keys to select an option-- -"; - string[] options = { "Play", "About", "Exit" }; - - Menu mainMenu = new(prompt, options); + StringBuilder prompt = new(); + prompt.AppendLine(); + prompt.AppendLine(" ██████╗ ██╗ ██╗ ██████╗ ██████╗ ██████╗ ██████╗ ██╗ ██╗ ██╗"); + prompt.AppendLine(" ██╔═══██╗██║ ██║██╔════╝ ██╔═══██╗██╔══██╗██╔═══██╗██║ ╚██╗ ██╔╝"); + prompt.AppendLine(" ██║ ██║██║ ██║██║ ███╗██║ ██║██████╔╝██║ ██║██║ ╚████╔╝ "); + prompt.AppendLine(" ██║ ██║██║ ██║██║ ██║██║ ██║██╔═══╝ ██║ ██║██║ ╚██╔╝ "); + prompt.AppendLine(" ╚██████╔╝███████╗██║╚██████╔╝╚██████╔╝██║ ╚██████╔╝███████╗██║ "); + prompt.AppendLine(" ╚═════╝ ╚══════╝╚═╝ ╚═════╝ ╚═════╝ ╚═╝ ╚═════╝ ╚══════╝╚═╝ "); + prompt.AppendLine(); + prompt.Append("You can exit the game at any time by pressing ESCAPE."); + prompt.AppendLine(); + prompt.Append("Use up and down arrow keys and enter to select an option:"); + Menu mainMenu = new(prompt.ToString(), + new string[] + { + "Play", + "About", + "Exit" + }); while (!CloseRequested) { @@ -71,7 +79,7 @@ private static void RunMainMenu() } } Console.Clear(); - Console.WriteLine("Press any key to exit the game..."); + Console.WriteLine("Oligopoly was closed. Press any key to continue..."); Console.CursorVisible = false; Console.ReadKey(true); } @@ -101,7 +109,7 @@ private static void RunStartMenu() Console.WriteLine(); Console.WriteLine("Press any key to continue..."); Console.CursorVisible = false; - Console.ReadKey(true); + CloseRequested = CloseRequested || Console.ReadKey(true).Key is ConsoleKey.Escape; RunGameMenu(); } @@ -112,7 +120,7 @@ private static void RunGameMenu() Random random = new(); // Start of the game cycle. - while (!isGameEnded) + while (!CloseRequested && !isGameEnded) { int currentEvent = random.Next(0, Events.Count); @@ -137,12 +145,12 @@ private static void RunGameMenu() } } - string prompt = "Use up and down arrow keys to select an option:"; + string prompt = "Use up and down arrow keys and enter to select an option:"; string[] options = { "Skip", "Buy", "Sell", "More About Companies" }; GameMenu gameMenu = new(prompt, options, currentEvent, money); int selectedOption = -1; - while (selectedOption is not 0) + while (!CloseRequested && selectedOption is not 0) { selectedOption = gameMenu.RunMenu(); switch (selectedOption) @@ -205,7 +213,7 @@ private static void RunActionMenu(ref double money, int currentEvent, bool isBuy Console.WriteLine($"You have bought {amountOfShares} shares of {Companies[selectedCompany].Name} company."); Console.WriteLine("Press any key to continue..."); Console.CursorVisible = false; - Console.ReadKey(true); + CloseRequested = CloseRequested || Console.ReadKey(true).Key is ConsoleKey.Escape; } else { @@ -217,14 +225,14 @@ private static void RunActionMenu(ref double money, int currentEvent, bool isBuy Console.WriteLine($"You have sold {amountOfShares} shares of {Companies[selectedCompany].Name} company."); Console.WriteLine("Press any key to continue..."); Console.CursorVisible = false; - Console.ReadKey(true); + CloseRequested = CloseRequested || Console.ReadKey(true).Key is ConsoleKey.Escape; } else { Console.WriteLine("Entered not a valid value"); Console.WriteLine("Press any key to continue..."); Console.CursorVisible = false; - Console.ReadKey(true); + CloseRequested = CloseRequested || Console.ReadKey(true).Key is ConsoleKey.Escape; } } } @@ -238,7 +246,7 @@ private static void DisplayMoreAboutCompaniesMenu() } Console.WriteLine("Press any key to exit the menu..."); Console.CursorVisible = false; - Console.ReadKey(true); + CloseRequested = CloseRequested || Console.ReadKey(true).Key is ConsoleKey.Escape; } /// @@ -271,7 +279,7 @@ private static void RunEndMenu(bool isWinner) Console.WriteLine(); Console.WriteLine("Press any key to continue..."); Console.CursorVisible = false; - Console.ReadKey(true); + CloseRequested = CloseRequested || Console.ReadKey(true).Key is ConsoleKey.Escape; } else { @@ -292,7 +300,7 @@ private static void RunEndMenu(bool isWinner) Console.WriteLine(); Console.WriteLine("Press any key to continue..."); Console.CursorVisible = false; - Console.ReadKey(true); + CloseRequested = CloseRequested || Console.ReadKey(true).Key is ConsoleKey.Escape; } } @@ -307,6 +315,6 @@ private static void DisplayAboutInfo() Console.WriteLine(); Console.WriteLine("Press any key to continue..."); Console.CursorVisible = false; - Console.ReadKey(true); + CloseRequested = CloseRequested || Console.ReadKey(true).Key is ConsoleKey.Escape; } } \ No newline at end of file From e82f354dc05c43a1033e6e35ed58df676c00f5fb Mon Sep 17 00:00:00 2001 From: ZacharyPatten Date: Wed, 10 May 2023 20:36:45 -0500 Subject: [PATCH 14/18] readme --- Projects/Oligopoly/GameMenu.cs | 1 - Projects/Oligopoly/README.md | 8 ++++---- 2 files changed, 4 insertions(+), 5 deletions(-) diff --git a/Projects/Oligopoly/GameMenu.cs b/Projects/Oligopoly/GameMenu.cs index af52e85d..28d12275 100644 --- a/Projects/Oligopoly/GameMenu.cs +++ b/Projects/Oligopoly/GameMenu.cs @@ -136,7 +136,6 @@ public int RunAmountMenu() break; } } - return amount; } } \ No newline at end of file diff --git a/Projects/Oligopoly/README.md b/Projects/Oligopoly/README.md index 1388a3d1..7236e23a 100644 --- a/Projects/Oligopoly/README.md +++ b/Projects/Oligopoly/README.md @@ -19,16 +19,16 @@ Hosted On GitHub Pages

+> **Note** This game was a *[Community Contribution](https://github.com/dotnet/dotnet-console-games/pull/72)! + Oligopoly is a stock market betting game. Buy stocks in a company and then try to sell them at a higher price. ## Input -- `↑`, `↓`, `←`, `→`: movement -- `enter`: play again +- `↑`, `↓`, `←`, `→`: menu selection +- `enter`: confirm - `escape`: exit game -> resizing the console window will cause the game to close - ## Downloads [win-x64](https://github.com/dotnet/dotnet-console-games/raw/binaries/win-x64/Oligopoly.exe) From a014b22251c60b31eaf7a765f0d31f5604cc5893 Mon Sep 17 00:00:00 2001 From: ZacharyPatten Date: Wed, 10 May 2023 20:39:35 -0500 Subject: [PATCH 15/18] csproj... --- Projects/Oligopoly/Oligopoly.csproj | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/Projects/Oligopoly/Oligopoly.csproj b/Projects/Oligopoly/Oligopoly.csproj index 0f06bb9f..f42ff9f4 100644 --- a/Projects/Oligopoly/Oligopoly.csproj +++ b/Projects/Oligopoly/Oligopoly.csproj @@ -6,11 +6,11 @@ enable - - + + - - + + From 4a9290e1c21217e64174c2c58f81f19cbb71f3ca Mon Sep 17 00:00:00 2001 From: Semion Medvedev <126599206+Fuinny@users.noreply.github.com> Date: Thu, 11 May 2023 18:04:08 +0300 Subject: [PATCH 16/18] =?UTF-8?q?Removed=20=20'=E2=86=90'=20and=20'?= =?UTF-8?q?=E2=86=92'=20buttons=20from=20readme=20as=20they=20are=20not=20?= =?UTF-8?q?needed=20for=20anything.?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- Projects/Oligopoly/README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Projects/Oligopoly/README.md b/Projects/Oligopoly/README.md index 7236e23a..ca003f32 100644 --- a/Projects/Oligopoly/README.md +++ b/Projects/Oligopoly/README.md @@ -25,7 +25,7 @@ Oligopoly is a stock market betting game. Buy stocks in a company and then try t ## Input -- `↑`, `↓`, `←`, `→`: menu selection +- `↑`, `↓`: menu selection - `enter`: confirm - `escape`: exit game From 55848d8705fd1bed7f168634b0f114ea5d751680 Mon Sep 17 00:00:00 2001 From: ZacharyPatten Date: Thu, 11 May 2023 15:35:41 -0500 Subject: [PATCH 17/18] oligopoly updates --- Projects/Oligopoly/Company.cs | 4 +- Projects/Oligopoly/Company.json | 10 +- Projects/Oligopoly/Event.cs | 7 +- Projects/Oligopoly/Event.json | 350 +++++------- Projects/Oligopoly/GameMenu.cs | 141 ----- Projects/Oligopoly/Menu.cs | 74 --- Projects/Oligopoly/Program.cs | 535 +++++++++++------- Projects/Oligopoly/README.md | 23 +- Projects/Website/Company.json | 38 ++ Projects/Website/Event.json | 302 ++++++++++ Projects/Website/Games/Oligopoly/Company.cs | 12 + Projects/Website/Games/Oligopoly/Event.cs | 11 + Projects/Website/Games/Oligopoly/Oligopoly.cs | 435 ++++++++++++++ Projects/Website/Pages/Oligopoly.razor | 52 ++ Projects/Website/Resources.cs | 22 + Projects/Website/Shared/NavMenu.razor | 5 + Projects/Website/Website.csproj | 8 +- 17 files changed, 1390 insertions(+), 639 deletions(-) delete mode 100644 Projects/Oligopoly/GameMenu.cs delete mode 100644 Projects/Oligopoly/Menu.cs create mode 100644 Projects/Website/Company.json create mode 100644 Projects/Website/Event.json create mode 100644 Projects/Website/Games/Oligopoly/Company.cs create mode 100644 Projects/Website/Games/Oligopoly/Event.cs create mode 100644 Projects/Website/Games/Oligopoly/Oligopoly.cs create mode 100644 Projects/Website/Pages/Oligopoly.razor diff --git a/Projects/Oligopoly/Company.cs b/Projects/Oligopoly/Company.cs index 078eaf67..6a7ea8c4 100644 --- a/Projects/Oligopoly/Company.cs +++ b/Projects/Oligopoly/Company.cs @@ -6,7 +6,7 @@ public class Company { public string Name { get; set; } public string Industry { get; set; } - public double SharePrice { get; set; } - public double ShareAmount { get; set; } + public decimal SharePrice { get; set; } + public int NumberOfShares { get; set; } public string Description { get; set; } } diff --git a/Projects/Oligopoly/Company.json b/Projects/Oligopoly/Company.json index fb987cc2..5ab373d6 100644 --- a/Projects/Oligopoly/Company.json +++ b/Projects/Oligopoly/Company.json @@ -3,21 +3,21 @@ "Name": "Bingoo", "Industry": "Web", "SharePrice": 1500, - "ShareAmount": 0, + "NumberOfShares": 0, "Description": "Promising search company. Leader in the development of various web services and web applications. Bingoo is known for its innovative and user-friendly products that aim to make the web more accessible and enjoyable. Bingoo also invests in artificial intelligence and machine learning to enhance its search engine and other services." }, { "Name": "Quantum Software", "Industry": "Software", "SharePrice": 2000, - "ShareAmount": 0, + "NumberOfShares": 0, "Description": "Software development company. The company is best known for its own operating system and various software packages. Quantum Software is a pioneer in the field of software engineering and has a reputation for creating reliable and fast products. Quantum Software also collaborates with other companies and organizations to provide customized solutions for their needs." }, { "Name": "Edison Incorporated", "Industry": "Energy", "SharePrice": 1000, - "ShareAmount": 0, + "NumberOfShares": 0, "Description": "An innovative company engaged in the development and production of electric vehicles, batteries, solar panels. Edison Incorporated is a leader in the green energy sector and strives to reduce the environmental impact of transportation and energy consumption. Edison Incorporated also offers a range of services and products for consumers and businesses who want to switch to renewable energy sources." }, { @@ -25,14 +25,14 @@ "Ticker": "NTF", "Industry": "Movies", "SharePrice": 800, - "ShareAmount": 0, + "NumberOfShares": 0, "Description": "A leading company in the field of online movies and series, also engaged in the development of video hosting. Netfilm is a popular platform for streaming and watching movies and series of various genres and languages. Netfilm also produces its own original content that attracts millions of viewers. Netfilm also provides a video hosting service that allows users to upload and share their own videos." }, { "Name": "COBRA Security Consulting", "Industry": "Army", "SharePrice": 1200, - "ShareAmount": 0, + "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." } ] \ No newline at end of file diff --git a/Projects/Oligopoly/Event.cs b/Projects/Oligopoly/Event.cs index c03acf1a..0badc581 100644 --- a/Projects/Oligopoly/Event.cs +++ b/Projects/Oligopoly/Event.cs @@ -4,9 +4,8 @@ namespace Oligopoly; public class Event { - public int Effect { get; set; } - public string CompanyName { get; set; } - public string Type { get; set; } public string Title { get; set; } - public string Content { get; set; } + public string Description { get; set; } + public string CompanyName { get; set; } + public int Effect { get; set; } } diff --git a/Projects/Oligopoly/Event.json b/Projects/Oligopoly/Event.json index 273dc6f1..867aeb5d 100644 --- a/Projects/Oligopoly/Event.json +++ b/Projects/Oligopoly/Event.json @@ -1,352 +1,302 @@ [ { - "Effect": 15, - "CompanyName": "Bingoo", - "Type": "Positive", "Title": "Bingoo announcing their new search engine", - "Content": "The company has announced its new search engine that will be more productive and user-friendly than the previous one. The search engine also uses artificial intelligence technology to improve search results and provide personalized recommendations to users. Experts predict that this will increase the value of the company\u2019s shares and attract more customers to its products and services." + "Description": "The company has announced its new search engine that will be more productive and user-friendly than the previous one. The search engine also uses artificial intelligence technology to improve search results and provide personalized recommendations to users. Experts predict that this will increase the value of the company\u2019s shares and attract more customers to its products and services.", + "CompanyName": "Bingoo", + "Effect": 15 }, { - "Effect": 10, - "CompanyName": "Bingoo", - "Type": "Positive", "Title": "Bingoo announcing their new AI assistant", - "Content": "Bingoo has unveiled its latest innovation: Bingy. An AI assistant that can chat, search, and create content for users. Bingy is powered by advanced natural language processing and machine learning technologies that enable it to understand and communicate fluently in multiple languages. Bingy is available as an application that users can install on their computers or phones for easy and convenient access." + "Description": "Bingoo has unveiled its latest innovation: Bingy. An AI assistant that can chat, search, and create content for users. Bingy is powered by advanced natural language processing and machine learning technologies that enable it to understand and communicate fluently in multiple languages. Bingy is available as an application that users can install on their computers or phones for easy and convenient access.", + "CompanyName": "Bingoo", + "Effect": 10 }, { - "Effect": 5, - "CompanyName": "Bingoo", - "Type": "Positive", "Title": "Bingoo introduces new features and improvements for its web services", - "Content": "Bingoo has introduced a series of new features and improvements for its web services. The new features include voice search, image recognition, personalized recommendations, smart suggestions, faster loading times, better security and more. The updates apply to Bingoo\u0027s popular web services such as Bingoo Mail, Bingoo Cloud, Bingoo Maps, Bingoo News and others." + "Description": "Bingoo has introduced a series of new features and improvements for its web services. The new features include voice search, image recognition, personalized recommendations, smart suggestions, faster loading times, better security and more. The updates apply to Bingoo\u0027s popular web services such as Bingoo Mail, Bingoo Cloud, Bingoo Maps, Bingoo News and others.", + "CompanyName": "Bingoo", + "Effect": 5 }, { - "Effect": 5, - "CompanyName": "Bingoo", - "Type": "Positive", "Title": "Bingoo creates a special event to attract more web developers", - "Content": "The event, called Bingoo Webathon, is a 24-hour online marathon of web development challenges, tutorials, demos and prizes. Bingoo said that the event is designed to showcase its web services and web applications and to inspire and motivate web developers of all levels and backgrounds to join its community and platform. " + "Description": "The event, called Bingoo Webathon, is a 24-hour online marathon of web development challenges, tutorials, demos and prizes. Bingoo said that the event is designed to showcase its web services and web applications and to inspire and motivate web developers of all levels and backgrounds to join its community and platform. ", + "CompanyName": "Bingoo", + "Effect": 5 }, { - "Effect": 5, - "CompanyName": "Bingoo", - "Type": "Positive", "Title": "Bingoo wins industry award for innovative web services", - "Content": "Bingoo has won an industry award for its innovative and user-friendly web services, including its search engine and web applications. The award recognizes Bingoo\u0027s commitment to providing the best possible user experiences and staying at the forefront of technology trends." + "Description": "Bingoo has won an industry award for its innovative and user-friendly web services, including its search engine and web applications. The award recognizes Bingoo\u0027s commitment to providing the best possible user experiences and staying at the forefront of technology trends.", + "CompanyName": "Bingoo", + "Effect": 5 }, { - "Effect": 15, - "CompanyName": "Bingoo", - "Type": "Negative", "Title": "Bingoo was accused of violating user privacy", - "Content": "The company was accused of stealing the personal data of its users and selling it to third parties without their consent. The case is currently under investigation by the authorities, but experts believe that this scandal will harm the company and its reputation. The company may face legal consequences and lose the trust of its users." + "Description": "The company was accused of stealing the personal data of its users and selling it to third parties without their consent. The case is currently under investigation by the authorities, but experts believe that this scandal will harm the company and its reputation. The company may face legal consequences and lose the trust of its users.", + "CompanyName": "Bingoo", + "Effect": -15 }, { - "Effect": 10, - "CompanyName": "Bingoo", - "Type": "Negative", "Title": "Bingoo\u0027s servers experience a service outage", - "Content": "Bingoo\u0027s services have been down for several hours due to a technical issue. Users have been unable to access their accounts, send emails, or use other Bingoo services during this time. The company has released a statement apologizing for the inconvenience and stating that it is working to resolve the issue as soon as possible." + "Description": "Bingoo\u0027s services have been down for several hours due to a technical issue. Users have been unable to access their accounts, send emails, or use other Bingoo services during this time. The company has released a statement apologizing for the inconvenience and stating that it is working to resolve the issue as soon as possible.", + "CompanyName": "Bingoo", + "Effect": -10 }, { - "Effect": 5, - "CompanyName": "Bingoo", - "Type": "Negative", "Title": "Bingoo missed out on a lucrative acquisition deal", - "Content": "Bingoo was in talks to acquire a promising startup that could have helped the company expand its services and increase its market share. However, the company\u0027s management decided to abandon the deal at the last minute, citing concerns about the startup\u0027s financial health and market potential. This decision was criticized by shareholders and industry experts, who believe that Bingoo missed a valuable opportunity to grow its business and compete with its rivals." + "Description": "Bingoo was in talks to acquire a promising startup that could have helped the company expand its services and increase its market share. However, the company\u0027s management decided to abandon the deal at the last minute, citing concerns about the startup\u0027s financial health and market potential. This decision was criticized by shareholders and industry experts, who believe that Bingoo missed a valuable opportunity to grow its business and compete with its rivals.", + "CompanyName": "Bingoo", + "Effect": -5 }, { - "Effect": 5, - "CompanyName": "Bingoo", - "Type": "Negative", "Title": "Bingoo criticized for excessive advertising in its products", - "Content": "Bingoo has been heavily criticized by its users for the excessive amount of ads present in its search engine. Many users have complained that the ads are intrusive and negatively affect their experience with the product. This has led to a decrease in user satisfaction and may ultimately lead to a decrease in sales." + "Description": "Bingoo has been heavily criticized by its users for the excessive amount of ads present in its search engine. Many users have complained that the ads are intrusive and negatively affect their experience with the product. This has led to a decrease in user satisfaction and may ultimately lead to a decrease in sales.", + "CompanyName": "Bingoo", + "Effect": -5 }, { - "Effect": 5, - "CompanyName": "Bingoo", - "Type": "Negative", "Title": "Bingoo terminates partnerships with phone manufacturers", - "Content": "Bingoo has announced that it will no longer be partnering with phone manufacturers to pre-install its search engine on their devices. This decision has been met with disappointment from phone manufacturers, as Bingoo\u0027s search engine is a popular choice among users. The move may lead to a decrease in Bingoo\u0027s market share and revenue, as users may choose other search engines instead." + "Description": "Bingoo has announced that it will no longer be partnering with phone manufacturers to pre-install its search engine on their devices. This decision has been met with disappointment from phone manufacturers, as Bingoo\u0027s search engine is a popular choice among users. The move may lead to a decrease in Bingoo\u0027s market share and revenue, as users may choose other search engines instead.", + "CompanyName": "Bingoo", + "Effect": -5 }, { - "Effect": 15, - "CompanyName": "Quantum Software", - "Type": "Positive", "Title": "Quantum Software announces new operating system", - "Content": "The company has introduced its new operating system from the Qore OS family at a presentation event. The company claims that the new operating system is more reliable and faster than the competitors\u2019 ones. The new operating system also has new features and functions that enhance the user experience. Experts expect the company\u2019s share price to rise and the new operating system to become popular among users." + "Description": "The company has introduced its new operating system from the Qore OS family at a presentation event. The company claims that the new operating system is more reliable and faster than the competitors\u2019 ones. The new operating system also has new features and functions that enhance the user experience. Experts expect the company\u2019s share price to rise and the new operating system to become popular among users.", + "CompanyName": "Quantum Software", + "Effect": 15 }, { - "Effect": 10, - "CompanyName": "Quantum Software", - "Type": "Positive", "Title": "Quantum Software announces update for Quantum Workflow", - "Content": "Quantum Software has just announced an exciting new update for its popular software package - Quantum Workflow. This new version is packed with innovative features and improvements that are sure to streamline your workflow and boost productivity. With its user-friendly interface and powerful capabilities, Quantum Workflow has already become a favorite among professionals in a variety of industries." + "Description": "Quantum Software has just announced an exciting new update for its popular software package - Quantum Workflow. This new version is packed with innovative features and improvements that are sure to streamline your workflow and boost productivity. With its user-friendly interface and powerful capabilities, Quantum Workflow has already become a favorite among professionals in a variety of industries.", + "CompanyName": "Quantum Software", + "Effect": 10 }, { - "Effect": 5, - "CompanyName": "Quantum Software", - "Type": "Positive", "Title": "Quantum Software presents its new development kit", - "Content": "The company has inoduced its new update for software development kit (QSDK). The new QSDK includes a powerful quantum simulator, a comprehensive set of libraries and frameworks, and a user-friendly development environment that makes it easy to get started with quantum programming. With QSDK developers also have access to new documnetation (QSDN), which will help them build robust and scalable applications." + "Description": "The company has inoduced its new update for software development kit (QSDK). The new QSDK includes a powerful quantum simulator, a comprehensive set of libraries and frameworks, and a user-friendly development environment that makes it easy to get started with quantum programming. With QSDK developers also have access to new documnetation (QSDN), which will help them build robust and scalable applications.", + "CompanyName": "Quantum Software", + "Effect": 5 }, { - "Effect": 5, - "CompanyName": "Quantum Software", - "Type": "Positive", "Title": "Quantum Software acquires a promising company", - "Content": "Quantum Software management has confirmed the purchase of a small software company. According to the company\u0027s management, the deal turned out to be very beneficial for both parties. The new software will soon be available on Quore OS operating systems and the company expects sales to increase in the near future." + "Description": "Quantum Software management has confirmed the purchase of a small software company. According to the company\u0027s management, the deal turned out to be very beneficial for both parties. The new software will soon be available on Quore OS operating systems and the company expects sales to increase in the near future.", + "CompanyName": "Quantum Software", + "Effect": 5 }, { - "Effect": 5, - "CompanyName": "Quantum Software", - "Type": "Positive", "Title": "Quantum Software invests in Quantum Sky development", - "Content": "Quantum Software announced a major investment in the development of Quantum Sky, its cloud platform and infrastructure for creating innovative solutions in artificial intelligence, big data and internet of things. Quantum Sky aims to provide customers with access to the most advanced quantum computing resources and services, as well as to foster collaboration and innovation among researchers, developers and entrepreneurs. Quantum Software expects that Quantum Sky will boost its revenue and market share" + "Description": "Quantum Software announced a major investment in the development of Quantum Sky, its cloud platform and infrastructure for creating innovative solutions in artificial intelligence, big data and internet of things. Quantum Sky aims to provide customers with access to the most advanced quantum computing resources and services, as well as to foster collaboration and innovation among researchers, developers and entrepreneurs. Quantum Software expects that Quantum Sky will boost its revenue and market share", + "CompanyName": "Quantum Software", + "Effect": 5 }, { - "Effect": 15, - "CompanyName": "Quantum Software", - "Type": "Negative", "Title": "The Antimonopoly Commission accused Quantum Software of illegally maintaining its monopoly position", - "Content": "The Antimonopoly Commission announced that it has launched an investigation into Quantum Software. The commission claims that Quantum Software has abused its dominant position by engaging in unfair practices such as predatory pricing, exclusive contracts, and bundling products. The commission said that these practices have harmed consumers and competitors, and stifled innovation in the software market. The company said that it operates in a highly competitive and dynamic environment, and that its success is based on its superior products and services." + "Description": "The Antimonopoly Commission announced that it has launched an investigation into Quantum Software. The commission claims that Quantum Software has abused its dominant position by engaging in unfair practices such as predatory pricing, exclusive contracts, and bundling products. The commission said that these practices have harmed consumers and competitors, and stifled innovation in the software market. The company said that it operates in a highly competitive and dynamic environment, and that its success is based on its superior products and services.", + "CompanyName": "Quantum Software", + "Effect": -15 }, { - "Effect": 10, - "CompanyName": "Quantum Software", - "Type": "Negative", "Title": "Quantum Software reported a data breach", - "Content": "Some of the company\u2019s servers were hacked by unknown attackers. The company is working with the police on this matter, but it is already known that their development of an unreleased operating system was stolen. The stolen data may contain sensitive information and secrets that could damage the company\u2019s business. The company may also face legal action from its partners and customers who were affected by the breach." + "Description": "Some of the company\u2019s servers were hacked by unknown attackers. The company is working with the police on this matter, but it is already known that their development of an unreleased operating system was stolen. The stolen data may contain sensitive information and secrets that could damage the company\u2019s business. The company may also face legal action from its partners and customers who were affected by the breach.", + "CompanyName": "Quantum Software", + "Effect": -10 }, { - "Effect": 5, - "CompanyName": "Quantum Software", - "Type": "Negative", "Title": "Users are unhappy with the latest Quore OS update", - "Content": "The latest update of Quore OS leads to numerous system breakdowns, and in some cases, loss of user data. Quantum Software has already apologized for the inconvenience and is working to remedy the situation. However, this event has caused many to consider alternative products, which could lead to a decrease in sales of Quantum Software." + "Description": "The latest update of Quore OS leads to numerous system breakdowns, and in some cases, loss of user data. Quantum Software has already apologized for the inconvenience and is working to remedy the situation. However, this event has caused many to consider alternative products, which could lead to a decrease in sales of Quantum Software.", + "CompanyName": "Quantum Software", + "Effect": -5 }, { - "Effect": 5, - "CompanyName": "Quantum Software", - "Type": "Negative", "Title": "Quantum Software breaks partnership with driver manufacturer", - "Content": "Quantum Software management announced the termination of cooperation with one of the largest manufacturers of drivers for their systems. The reasons for this abrupt decision are not clear. The company said it is looking into alternative solutions to this problem. However, this may cause their operating systems to fall behind technically and reduce profits." + "Description": "Quantum Software management announced the termination of cooperation with one of the largest manufacturers of drivers for their systems. The reasons for this abrupt decision are not clear. The company said it is looking into alternative solutions to this problem. However, this may cause their operating systems to fall behind technically and reduce profits.", + "CompanyName": "Quantum Software", + "Effect": -5 }, { - "Effect": 5, - "CompanyName": "Quantum Software", - "Type": "Negative", "Title": "Quantum Software faced mass layoffs", - "Content": "The company is facing massive layoffs. Employees say that before the release of the next major update, management began to set impossible tasks for them and give them the shortest possible time. The company\u0027s management has not yet commented on this, but this news will definitely not benefit the company\u0027s share prices." + "Description": "The company is facing massive layoffs. Employees say that before the release of the next major update, management began to set impossible tasks for them and give them the shortest possible time. The company\u0027s management has not yet commented on this, but this news will definitely not benefit the company\u0027s share prices.", + "CompanyName": "Quantum Software", + "Effect": -5 }, { - "Effect": 15, - "CompanyName": "Edison Incorporated", - "Type": "Positive", "Title": "Edison Incorporated presents its new electric car", - "Content": "The company\u2019s new electric cars with autopilot function went on sale in several countries. Edison Incorporated has managed to reduce the charging time of the car and increase its battery life by using innovative technology and materials. The first owners of electric cars are already leaving positive reviews and praising the performance and design of the car. The company expects to increase its sales and market share in the electric vehicle industry." + "Description": "The company\u2019s new electric cars with autopilot function went on sale in several countries. Edison Incorporated has managed to reduce the charging time of the car and increase its battery life by using innovative technology and materials. The first owners of electric cars are already leaving positive reviews and praising the performance and design of the car. The company expects to increase its sales and market share in the electric vehicle industry.", + "CompanyName": "Edison Incorporated", + "Effect": 15 }, { - "Effect": 10, - "CompanyName": "Edison Incorporated", - "Type": "Positive", "Title": "Edison Incorporated enters the Asian market", - "Content": "The company has announced that it will start selling its electric vehicles in several Asian countries, including China, Japan, and India. The company said that it sees a huge potential for growth in these markets, as the demand for green and smart transportation is increasing. Edison Incorporated expects that this move will boost its sales and revenue, as well as its brand recognition and reputation." + "Description": "The company has announced that it will start selling its electric vehicles in several Asian countries, including China, Japan, and India. The company said that it sees a huge potential for growth in these markets, as the demand for green and smart transportation is increasing. Edison Incorporated expects that this move will boost its sales and revenue, as well as its brand recognition and reputation.", + "CompanyName": "Edison Incorporated", + "Effect": 10 }, { - "Effect": 5, - "CompanyName": "Edison Incorporated", - "Type": "Positive", "Title": "Edison Incorporated launches a successful advertising campaign", - "Content": "The company has launched a new advertising campaign to promote its electric vehicles and solar panels. The campaign features celebrities, influencers, and ordinary people who share their positive experiences with the company\u2019s products and services. The campaign also highlights the environmental and economic benefits of switching to renewable energy sources. The campaign has received a lot of positive feedback and attention from the public and the media, and has increased the company\u2019s popularity and customer loyalty." + "Description": "The company has launched a new advertising campaign to promote its electric vehicles and solar panels. The campaign features celebrities, influencers, and ordinary people who share their positive experiences with the company\u2019s products and services. The campaign also highlights the environmental and economic benefits of switching to renewable energy sources. The campaign has received a lot of positive feedback and attention from the public and the media, and has increased the company\u2019s popularity and customer loyalty.", + "CompanyName": "Edison Incorporated", + "Effect": 5 }, { - "Effect": 5, - "CompanyName": "Edison Incorporated", - "Type": "Positive", "Title": "Edison Incorporated develops a more efficient electric engine", - "Content": "Edison Incorporated has developed a new electric engine that is more efficient and powerful than its previous models. The new engine uses less energy and produces less noise and emissions. The company said that the new engine will improve the performance and range of its electric vehicles, as well as reduce the maintenance costs and carbon footprint. The company plans to implement the new engine in its upcoming models and offer it as an upgrade option for existing customers. " + "Description": "Edison Incorporated has developed a new electric engine that is more efficient and powerful than its previous models. The new engine uses less energy and produces less noise and emissions. The company said that the new engine will improve the performance and range of its electric vehicles, as well as reduce the maintenance costs and carbon footprint. The company plans to implement the new engine in its upcoming models and offer it as an upgrade option for existing customers. ", + "CompanyName": "Edison Incorporated", + "Effect": 5 }, { - "Effect": 5, - "CompanyName": "Edison Incorporated", - "Type": "Positive", "Title": "Edison Incorporated reduces the prices of its products", - "Content": "The company has announced that it will reduce the prices of its electric vehicles and solar panels by 10%. Edison Incorporated said that this decision is motivated by its desire to make its products more affordable and accessible to a wider range of customers. The company also said that it has achieved significant cost reductions thanks to its technological innovations and economies of scale. The price reduction is expected to increase the demand and sales of the company\u2019s products, as well as its market share and competitiveness." + "Description": "The company has announced that it will reduce the prices of its electric vehicles and solar panels by 10%. Edison Incorporated said that this decision is motivated by its desire to make its products more affordable and accessible to a wider range of customers. The company also said that it has achieved significant cost reductions thanks to its technological innovations and economies of scale. The price reduction is expected to increase the demand and sales of the company\u2019s products, as well as its market share and competitiveness.", + "CompanyName": "Edison Incorporated", + "Effect": 5 }, { - "Effect": 15, - "CompanyName": "Edison Incorporated", - "Type": "Negative", "Title": "Edison Incorporated is facing production difficulties", - "Content": "The company said it was having difficulty mining lithium, which is a key material for producing batteries for electric vehicles. The company blamed the shortage of lithium on environmental issues and political instability in some regions. Edison Incorporated assures that the difficulties are temporary and that it is looking for alternative sources of lithium. But we can already say that they harmed the company\u2019s production and profits." + "Description": "The company said it was having difficulty mining lithium, which is a key material for producing batteries for electric vehicles. The company blamed the shortage of lithium on environmental issues and political instability in some regions. Edison Incorporated assures that the difficulties are temporary and that it is looking for alternative sources of lithium. But we can already say that they harmed the company\u2019s production and profits.", + "CompanyName": "Edison Incorporated", + "Effect": -15 }, { - "Effect": 10, - "CompanyName": "Edison Incorporated", - "Type": "Negative", "Title": "Edison Incorporated recalls some of its electric vehicles ", - "Content": "Edison Incorporated has announced that it will recall some of its electric vehicles due to a defect in the battery system that could cause overheating and fire. The company said that the recall affects a small percentage of its vehicles and that it will provide free repairs and replacements to the affected customers. The company apologized for the inconvenience and said that it is taking all the necessary measures to ensure the safety and quality of its products. However, this incident has damaged the company\u2019s reputation and customer confidence." + "Description": "Edison Incorporated has announced that it will recall some of its electric vehicles due to a defect in the battery system that could cause overheating and fire. The company said that the recall affects a small percentage of its vehicles and that it will provide free repairs and replacements to the affected customers. The company apologized for the inconvenience and said that it is taking all the necessary measures to ensure the safety and quality of its products. However, this incident has damaged the company\u2019s reputation and customer confidence.", + "CompanyName": "Edison Incorporated", + "Effect": -10 }, { - "Effect": 5, - "CompanyName": "Edison Incorporated", - "Type": "Negative", "Title": "Edison Incorporated faces increased competition in the electric vehicle market", - "Content": "The company faces increased competition from other companies that are also producing and selling electric vehicles. Some of these competitors offer similar or better products at lower prices or with more features and options. The company said that it is confident in its products and services and that it will continue to innovate and improve its offerings. However, this may affect the company\u2019s sales and market share, as customers may choose other alternatives. " + "Description": "The company faces increased competition from other companies that are also producing and selling electric vehicles. Some of these competitors offer similar or better products at lower prices or with more features and options. The company said that it is confident in its products and services and that it will continue to innovate and improve its offerings. However, this may affect the company\u2019s sales and market share, as customers may choose other alternatives. ", + "CompanyName": "Edison Incorporated", + "Effect": -5 }, { - "Effect": 5, - "CompanyName": "Edison Incorporated", - "Type": "Negative", "Title": "Customers criticize Edison Incorporated", - "Content": "The company has received some criticism from its customers who are unhappy with some aspects of its products and services. The customers have complained about the high prices, long delivery times, and poor customer service of the company. The company has responded to the criticism by acknowledging the issues and promising to improve its performance and quality. Edison Incorporated said that it values its customers\u2019 feedback and that it will use it to enhance its products and services. The company hopes that this will restore its customer trust and satisfaction." + "Description": "The company has received some criticism from its customers who are unhappy with some aspects of its products and services. The customers have complained about the high prices, long delivery times, and poor customer service of the company. The company has responded to the criticism by acknowledging the issues and promising to improve its performance and quality. Edison Incorporated said that it values its customers\u2019 feedback and that it will use it to enhance its products and services. The company hopes that this will restore its customer trust and satisfaction.", + "CompanyName": "Edison Incorporated", + "Effect": -5 }, { - "Effect": 5, - "CompanyName": "Edison Incorporated", - "Type": "Negative", "Title": "Edison Incorporated reports problems with its autopilot system", - "Content": "The company has reported that some of its electric vehicles have experienced problems with their autopilot system. The system is supposed to assist the driver in steering, braking, and changing lanes, but some customers have reported that it has malfunctioned or failed to respond in some situations. Edison Incorporated said that it is investigating the cause of the problems and that it will issue a software update to fix them. The company also advised its customers to always pay attention and be ready to take over the control of the vehicle when using the autopilot system. The problems have raised some safety and reliability concerns among the customers and the regulators." + "Description": "The company has reported that some of its electric vehicles have experienced problems with their autopilot system. The system is supposed to assist the driver in steering, braking, and changing lanes, but some customers have reported that it has malfunctioned or failed to respond in some situations. Edison Incorporated said that it is investigating the cause of the problems and that it will issue a software update to fix them. The company also advised its customers to always pay attention and be ready to take over the control of the vehicle when using the autopilot system. The problems have raised some safety and reliability concerns among the customers and the regulators.", + "CompanyName": "Edison Incorporated", + "Effect": -5 }, { - "Effect": 15, - "CompanyName": "Netfilm", - "Type": "Positive", "Title": "Netfilm announces new series", - "Content": "The company has confirmed the creation of its new series, which will be exclusive to its platform. The title and plot are still unknown, but the public already looks interested and curious. The company said that the new series will be a high-quality production with a talented cast and crew. The company hopes that the new series will attract more subscribers and viewers to its platform." + "Description": "The company has confirmed the creation of its new series, which will be exclusive to its platform. The title and plot are still unknown, but the public already looks interested and curious. The company said that the new series will be a high-quality production with a talented cast and crew. The company hopes that the new series will attract more subscribers and viewers to its platform.", + "CompanyName": "Netfilm", + "Effect": 15 }, { - "Effect": 10, - "CompanyName": "Netfilm", - "Type": "Positive", "Title": "Netfilm wins awards for its original content", - "Content": "The company has won several awards for its original content, including movies and series. The awards recognize Netfilm\u2019s creativity and excellence in producing and streaming high-quality content that appeals to a wide audience. The awards also boost Netfilm\u2019s reputation and popularity in the online streaming industry." + "Description": "The company has won several awards for its original content, including movies and series. The awards recognize Netfilm\u2019s creativity and excellence in producing and streaming high-quality content that appeals to a wide audience. The awards also boost Netfilm\u2019s reputation and popularity in the online streaming industry.", + "CompanyName": "Netfilm", + "Effect": 10 }, { - "Effect": 5, - "CompanyName": "Netfilm", - "Type": "Positive", "Title": "Netfilm improves its video hosting service", - "Content": "Netfilm has announced that it has improved its video hosting service, which allows users to upload and stream their own videos on its platform. The company said that the improvement will enhance the quality, speed, and security of the video hosting service, as well as provide more options and features for users. The company said that the improvement will attract more users and creators to its platform, and increase its revenue and profit." + "Description": "Netfilm has announced that it has improved its video hosting service, which allows users to upload and stream their own videos on its platform. The company said that the improvement will enhance the quality, speed, and security of the video hosting service, as well as provide more options and features for users. The company said that the improvement will attract more users and creators to its platform, and increase its revenue and profit.", + "CompanyName": "Netfilm", + "Effect": 5 }, { - "Effect": 5, - "CompanyName": "Netfilm", - "Type": "Positive", "Title": "Netfilm offers a subscription discount", - "Content": "Netfilm has announced that it will offer a subscription discount for its customers who sign up for a year or more. The company said that the discount will make its service more affordable and accessible for its customers, as well as increase its customer loyalty and retention. The company said that the discount is part of its customer appreciation and promotion campaign." + "Description": "Netfilm has announced that it will offer a subscription discount for its customers who sign up for a year or more. The company said that the discount will make its service more affordable and accessible for its customers, as well as increase its customer loyalty and retention. The company said that the discount is part of its customer appreciation and promotion campaign.", + "CompanyName": "Netfilm", + "Effect": 5 }, { - "Effect": 5, - "CompanyName": "Netfilm", - "Type": "Positive", "Title": "Netfilm rewards its loyal customers", - "Content": "Netfilm has announced that it has rewarded its loyal customers with special offers and benefits. The company said that it has launched a loyalty program that allows its customers to earn points and redeem them for discounts, free trials, or exclusive content. The company also said that it has sent personalized recommendations and gifts to its customers, based on their preferences and interests." + "Description": "Netfilm has announced that it has rewarded its loyal customers with special offers and benefits. The company said that it has launched a loyalty program that allows its customers to earn points and redeem them for discounts, free trials, or exclusive content. The company also said that it has sent personalized recommendations and gifts to its customers, based on their preferences and interests.", + "CompanyName": "Netfilm", + "Effect": 5 }, { - "Effect": 15, - "CompanyName": "Netfilm", - "Type": "Negative", "Title": "Netfilm faced lawsuit", - "Content": "Netfilm sued by movie studios for streaming their content without permission. Netfilm denies the charges and says it has a fair use policy that allows it to stream content for educational and entertainment purposes. The lawsuit could affect the online streaming industry and set a precedent for future cases. The company may have to pay a large amount of money in damages or remove some content from its platform." + "Description": "Netfilm sued by movie studios for streaming their content without permission. Netfilm denies the charges and says it has a fair use policy that allows it to stream content for educational and entertainment purposes. The lawsuit could affect the online streaming industry and set a precedent for future cases. The company may have to pay a large amount of money in damages or remove some content from its platform.", + "CompanyName": "Netfilm", + "Effect": -15 }, { - "Effect": 10, - "CompanyName": "Netfilm", - "Type": "Negative", "Title": "Netfilm delays new releases", - "Content": "Netfilm has announced that it will delay some of its new releases, due to production difficulties or quality issues. The company said that it wants to ensure that its new releases meet its high standards and expectations, and that it apologizes for any inconvenience caused to its customers. However, this decision has disappointed some of its customers who were eagerly waiting for the new releases, and has given an advantage to its competitors who have released their content on time." + "Description": "Netfilm has announced that it will delay some of its new releases, due to production difficulties or quality issues. The company said that it wants to ensure that its new releases meet its high standards and expectations, and that it apologizes for any inconvenience caused to its customers. However, this decision has disappointed some of its customers who were eagerly waiting for the new releases, and has given an advantage to its competitors who have released their content on time.", + "CompanyName": "Netfilm", + "Effect": -10 }, { - "Effect": 5, - "CompanyName": "Netfilm", - "Type": "Negative", "Title": "Netfilm faces controversy over its content", - "Content": "Netfilm has faced controversy over some of its content, which has been accused of being offensive, inappropriate, or inaccurate. Some of its content has sparked backlash and criticism from various groups and individuals, who have demanded that Netfilm remove or apologize for the content. Some of its content has also been banned or censored in some countries or regions, due to legal or cultural reasons. This controversy has harmed Netfilm\u2019s image and reputation, as well as caused some of its customers and partners to boycott or cancel its service." + "Description": "Netfilm has faced controversy over some of its content, which has been accused of being offensive, inappropriate, or inaccurate. Some of its content has sparked backlash and criticism from various groups and individuals, who have demanded that Netfilm remove or apologize for the content. Some of its content has also been banned or censored in some countries or regions, due to legal or cultural reasons. This controversy has harmed Netfilm\u2019s image and reputation, as well as caused some of its customers and partners to boycott or cancel its service.", + "CompanyName": "Netfilm", + "Effect": -5 }, { - "Effect": 5, - "CompanyName": "Netfilm", - "Type": "Negative", "Title": "Netfilm faces piracy threat", - "Content": "Netfilm has faced piracy threat, which has affected its revenue and profit. The company has discovered that some of its content has been illegally copied or distributed by unauthorized parties or platforms. The company has also found that some of its customers have shared their accounts or passwords with others, who have accessed its service without paying. The company said that it is taking measures to protect its intellectual property rights and to prevent piracy. However, this situation has reduced Netfilm\u2019s income and market share, as well as damaged its exclusivity and value." + "Description": "Netfilm has faced piracy threat, which has affected its revenue and profit. The company has discovered that some of its content has been illegally copied or distributed by unauthorized parties or platforms. The company has also found that some of its customers have shared their accounts or passwords with others, who have accessed its service without paying. The company said that it is taking measures to protect its intellectual property rights and to prevent piracy. However, this situation has reduced Netfilm\u2019s income and market share, as well as damaged its exclusivity and value.", + "CompanyName": "Netfilm", + "Effect": -5 }, { - "Effect": 5, - "CompanyName": "Netfilm", - "Type": "Negative", "Title": "Netfilm faces employee strike", - "Content": "Netfilm has faced employee strike, which has disrupted its operations and productivity. The company\u2019s employees have gone on strike to demand better working conditions, wages, and benefits. The company said that it is negotiating with the employees and their representatives, and that it hopes to reach a fair and reasonable agreement. However, this situation has affected Netfilm\u2019s performance and output, as well as its relationship and trust with its employees." + "Description": "Netfilm has faced employee strike, which has disrupted its operations and productivity. The company\u2019s employees have gone on strike to demand better working conditions, wages, and benefits. The company said that it is negotiating with the employees and their representatives, and that it hopes to reach a fair and reasonable agreement. However, this situation has affected Netfilm\u2019s performance and output, as well as its relationship and trust with its employees.", + "CompanyName": "Netfilm", + "Effect": -5 }, { - "Effect": 15, - "CompanyName": "COBRA Security Consulting", - "Type": "Positive", "Title": "COBRA Security Consulting signs a contract with the government", - "Content": "The company signed a contract with the government to ensure the security of state facilities such as military bases, power plants, airports, etc. COBRA operatives are already arriving at the facilities and setting up security measures. The exact amount of the contract was not disclosed, but it is already clear that the contract is beneficial to both parties. The contract will provide a stable income for the company and enhance the security of the state facilities." + "Description": "The company signed a contract with the government to ensure the security of state facilities such as military bases, power plants, airports, etc. COBRA operatives are already arriving at the facilities and setting up security measures. The exact amount of the contract was not disclosed, but it is already clear that the contract is beneficial to both parties. The contract will provide a stable income for the company and enhance the security of the state facilities.", + "CompanyName": "COBRA Security Consulting", + "Effect": 15 }, { - "Effect": 10, - "CompanyName": "COBRA Security Consulting", - "Type": "Positive", "Title": "The United Nations gives permission for COBRA Security Consulting to operate in new territories", - "Content": "The United Nations has granted permission for COBRA Security Consulting to operate in new territories that are under its supervision and protection. The permission allows the company to provide security services and solutions to various clients and sectors in these territories, such as humanitarian organizations, businesses, and governments. The company said that the permission is a sign of its credibility and reputation, as well as an opportunity to expand its scope and impact." + "Description": "The United Nations has granted permission for COBRA Security Consulting to operate in new territories that are under its supervision and protection. The permission allows the company to provide security services and solutions to various clients and sectors in these territories, such as humanitarian organizations, businesses, and governments. The company said that the permission is a sign of its credibility and reputation, as well as an opportunity to expand its scope and impact.", + "CompanyName": "COBRA Security Consulting", + "Effect": 10 }, { - "Effect": 5, - "CompanyName": "COBRA Security Consulting", - "Type": "Positive", "Title": "COBRA Security Consulting successfully completes the rescue operation", - "Content": "COBRA Security Consulting announced that it has successfully completed the rescue operation of a group of hostages held by a terrorist organization in a remote location. The operation involved a team of highly trained and experienced operatives who infiltrated the enemy camp and freed the hostages without any casualties. The hostages were then transported to a safe place and reunited with their families. The company said that the operation was a testament to its skills and dedication to saving lives." + "Description": "COBRA Security Consulting announced that it has successfully completed the rescue operation of a group of hostages held by a terrorist organization in a remote location. The operation involved a team of highly trained and experienced operatives who infiltrated the enemy camp and freed the hostages without any casualties. The hostages were then transported to a safe place and reunited with their families. The company said that the operation was a testament to its skills and dedication to saving lives.", + "CompanyName": "COBRA Security Consulting", + "Effect": 5 }, { - "Effect": 5, - "CompanyName": "COBRA Security Consulting", - "Type": "Positive", "Title": "COBRA Security Consulting unveils its new technology and equipment", - "Content": "COBRA Security Consulting unveils its new technology and equipment for its operatives. The new technology and equipment include advanced drones, sensors, weapons, and communication devices that enhance the capabilities and safety of its operatives. The company said that the new technology and equipment will give it an edge over its competitors and adversaries" + "Description": "COBRA Security Consulting unveils its new technology and equipment for its operatives. The new technology and equipment include advanced drones, sensors, weapons, and communication devices that enhance the capabilities and safety of its operatives. The company said that the new technology and equipment will give it an edge over its competitors and adversaries", + "CompanyName": "COBRA Security Consulting", + "Effect": 5 }, { - "Effect": 5, - "CompanyName": "COBRA Security Consulting", - "Type": "Positive", "Title": "COBRA Security Consulting secures a supply contract with government", - "Content": "COBRA Security Consulting revealed that it has provided security supplies to the government as part of a contract to equip its forces and agencies with the latest security equipment and technology. The contract will enhance the company\u2019s revenue and reputation, as well as show its competence and dependability of its products and services. The company said that the contract is an acknowledgment of its innovation and excellence, and that it is pleased and honored to collaborate with the government." + "Description": "COBRA Security Consulting revealed that it has provided security supplies to the government as part of a contract to equip its forces and agencies with the latest security equipment and technology. The contract will enhance the company\u2019s revenue and reputation, as well as show its competence and dependability of its products and services. The company said that the contract is an acknowledgment of its innovation and excellence, and that it is pleased and honored to collaborate with the government.", + "CompanyName": "COBRA Security Consulting", + "Effect": 5 }, { - "Effect": 15, - "CompanyName": "COBRA Security Consulting", - "Type": "Negative", "Title": "COBRA Security Consulting is being criticized for their violent actions", - "Content": "COBRA Security Consulting has been criticized for its harsh actions in the Middle East on the territory of the facilities under its protection. The company\u2019s management states that this is necessary to ensure security in the region and prevent terrorist attacks. However, some human rights organizations and media outlets accuse the company of using excessive force and violating international law. Government has already become interested in this case, and most likely the company will face punishment such as sanctions, fines, or termination of contracts." + "Description": "COBRA Security Consulting has been criticized for its harsh actions in the Middle East on the territory of the facilities under its protection. The company\u2019s management states that this is necessary to ensure security in the region and prevent terrorist attacks. However, some human rights organizations and media outlets accuse the company of using excessive force and violating international law. Government has already become interested in this case, and most likely the company will face punishment such as sanctions, fines, or termination of contracts.", + "CompanyName": "COBRA Security Consulting", + "Effect": -15 }, { - "Effect": 10, - "CompanyName": "COBRA Security Consulting", - "Type": "Negative", "Title": "COBRA Security Consulting brigades were captured", - "Content": "COBRA Security Consulting confirmed that some of its brigades were captured by a rebel group during a security operation. The brigades were part of a team that was providing security and escort to a convoy of humanitarian aid workers who were delivering supplies to a war-torn area. The rebel group ambushed the convoy and took the brigades as hostages. The company said that it is in contact with the rebel group and is negotiating for the release of the brigades. The company also said that it is doing everything in its power to ensure the safety and well-being of its brigades." + "Description": "COBRA Security Consulting confirmed that some of its brigades were captured by a rebel group during a security operation. The brigades were part of a team that was providing security and escort to a convoy of humanitarian aid workers who were delivering supplies to a war-torn area. The rebel group ambushed the convoy and took the brigades as hostages. The company said that it is in contact with the rebel group and is negotiating for the release of the brigades. The company also said that it is doing everything in its power to ensure the safety and well-being of its brigades.", + "CompanyName": "COBRA Security Consulting", + "Effect": -10 }, { - "Effect": 5, - "CompanyName": "COBRA Security Consulting", - "Type": "Negative", "Title": "Fighter of COBRA Security Consulting was shot down", - "Content": "COBRA Security Consulting confirmed that one of its fighters was shot down by an unknown enemy during a security mission. The fighter was part of a team that was providing air support to a client who was under attack by a hostile force. The fighter was hit by a missile and crashed in a remote area. The company said that it is trying to locate and rescue the pilot, who is presumed to be alive. The company also said that it is investigating the identity and motive of the enemy who shot down the fighter." + "Description": "COBRA Security Consulting confirmed that one of its fighters was shot down by an unknown enemy during a security mission. The fighter was part of a team that was providing air support to a client who was under attack by a hostile force. The fighter was hit by a missile and crashed in a remote area. The company said that it is trying to locate and rescue the pilot, who is presumed to be alive. The company also said that it is investigating the identity and motive of the enemy who shot down the fighter.", + "CompanyName": "COBRA Security Consulting", + "Effect": -5 }, { - "Effect": 5, - "CompanyName": "COBRA Security Consulting", - "Type": "Negative", "Title": "COBRA Security Consulting vehicle involved in a deadly accident", - "Content": "A COBRA Security Consulting vehicle has been involved in a serious accident that resulted in several casualties, including civilians and company personnel. The accident happened during a convoy operation, and the cause of the accident is still under investigation. The company is offering support and compensation to the victims and their families, but it may face legal action and reputational damage from the incident." + "Description": "A COBRA Security Consulting vehicle has been involved in a serious accident that resulted in several casualties, including civilians and company personnel. The accident happened during a convoy operation, and the cause of the accident is still under investigation. The company is offering support and compensation to the victims and their families, but it may face legal action and reputational damage from the incident.", + "CompanyName": "COBRA Security Consulting", + "Effect": -5 }, { - "Effect": 5, - "CompanyName": "COBRA Security Consulting", - "Type": "Negative", "Title": "COBRA Security Consulting staff arrested for illegal activity", - "Content": "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." + "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 } ] \ No newline at end of file diff --git a/Projects/Oligopoly/GameMenu.cs b/Projects/Oligopoly/GameMenu.cs deleted file mode 100644 index 28d12275..00000000 --- a/Projects/Oligopoly/GameMenu.cs +++ /dev/null @@ -1,141 +0,0 @@ -using System; - -namespace Oligopoly; - -public class GameMenu : Menu -{ - private int CurrentEvent; - private double Money; - - /// - /// Initializes a new instance of the GameMenu class with given parameters. - /// - /// The prompt to display above the menu. - /// The options to display in the menu. - /// The text output delay. Have to be a positive integer or zero. - /// The integer that represents current event. - public GameMenu(string prompt, string[] options, int currentEvent, double money) - : base(prompt, options) - { - CurrentEvent = currentEvent; - Money = money; - } - - /// - /// Displays menu to the console and redraws it when user select other option. - /// - protected override void DisplayMenu() - { - // column widths - const int c0 = 30; - const int c1 = 10; - const int c2 = 19; - const int c3 = 17; - - Console.WriteLine($"╔═{new('═', c0)}═╤═{new('═', c1)}═╤═{new('═', c2)}═╤═{new('═', c3)}═╗"); - Console.WriteLine($"║ {"Company", -c0} │ {"Industry", c1} │ {"Share Price", c2} │ {"You Have", c3} ║"); - Console.WriteLine($"╟─{new('─', c0)}─┼─{new('─', c1)}─┼─{new('─', c2)}─┼─{new('─', c3)}─╢"); - foreach (Company company in Program.Companies) - { - Console.WriteLine($"║ {company.Name, -c0} │ {company.Industry, c1} │ {company.SharePrice, c2} │ {company.ShareAmount, c3} ║"); - } - Console.WriteLine($"╚═{new('═', c0)}═╧═{new('═', c1)}═╧═{new('═', c2)}═╧═{new('═', c3)}═╝"); - Console.WriteLine(); - - Console.WriteLine($"{Program.Events[CurrentEvent].Title}"); - Console.WriteLine(); - Console.WriteLine($"{Program.Events[CurrentEvent].Content}"); - Console.WriteLine(); - - Console.WriteLine($"You have: {Math.Round(Money, 2)}$"); - Console.WriteLine(); - - Console.WriteLine(Prompt); - - for (int i = 0; i < Options.Length; i++) - { - string currentOption = Options[i]; - if (i == SelectedIndex) - { - (Console.BackgroundColor, Console.ForegroundColor) = (Console.ForegroundColor, Console.BackgroundColor); - Console.WriteLine($"[*] {currentOption}"); - Console.ResetColor(); - } - else - { - Console.WriteLine($"[ ] {currentOption}"); - } - } - } - - /// - /// Runs the menu. - /// - /// An integer that represents the selected option. - public override int RunMenu() - { - ConsoleKey keyPressed = default; - while (!Program.CloseRequested && keyPressed is not ConsoleKey.Enter) - { - Console.Clear(); - DisplayMenu(); - Console.CursorVisible = false; - keyPressed = Console.ReadKey().Key; - switch (keyPressed) - { - case ConsoleKey.UpArrow: - SelectedIndex = SelectedIndex is 0 ? Options.Length - 1 : SelectedIndex - 1; - break; - case ConsoleKey.DownArrow: - SelectedIndex = SelectedIndex == Options.Length - 1 ? 0 : SelectedIndex + 1; - break; - case ConsoleKey.Escape: - Program.CloseRequested = true; - break; - } - } - - return SelectedIndex; - } - - /// - /// Runs the amount menu. - /// - /// An integer, that represents the amount of shares. - public int RunAmountMenu() - { - ConsoleKey keyPressed = default; - int amount = 0; - while (!Program.CloseRequested && (keyPressed is not ConsoleKey.Enter || SelectedIndex is not 2)) - { - Console.Clear(); - DisplayMenu(); - Console.WriteLine($"Current amount: {amount}"); - Console.CursorVisible = false; - keyPressed = Console.ReadKey().Key; - switch (keyPressed) - { - case ConsoleKey.UpArrow: - SelectedIndex = SelectedIndex is 0 ? Options.Length - 1 : SelectedIndex - 1; - break; - case ConsoleKey.DownArrow: - SelectedIndex = SelectedIndex == Options.Length - 1 ? 0 : SelectedIndex + 1; - break; - case ConsoleKey.Enter: - if (SelectedIndex is 0) - { - amount++; - } - else if (SelectedIndex is 1 && amount > 0) - { - amount--; - } - break; - case ConsoleKey.Escape: - Program.CloseRequested = true; - break; - } - } - return amount; - } -} \ No newline at end of file diff --git a/Projects/Oligopoly/Menu.cs b/Projects/Oligopoly/Menu.cs deleted file mode 100644 index f59bf6c6..00000000 --- a/Projects/Oligopoly/Menu.cs +++ /dev/null @@ -1,74 +0,0 @@ -using System; - -namespace Oligopoly; - -public class Menu -{ - protected int SelectedIndex; - protected string Prompt; - protected string[] Options; - - /// - /// Initializes a new instance of the Menu class with given prompt, options and output delay. - /// - /// The prompt to display above the menu. - /// The options to display in the menu. - /// The text output delay. Have to be a positive integer or zero! - public Menu(string prompt, string[] options) - { - Prompt = prompt; - Options = options; - SelectedIndex = 0; - } - - /// - /// Displays menu to the console and redraws it when user select other option. - /// - protected virtual void DisplayMenu() - { - Console.WriteLine(Prompt); - for (int i = 0; i < Options.Length; i++) - { - string currentOption = Options[i]; - if (i == SelectedIndex) - { - (Console.BackgroundColor, Console.ForegroundColor) = (Console.ForegroundColor, Console.BackgroundColor); - Console.WriteLine($"[*] {currentOption}"); - Console.ResetColor(); - } - else - { - Console.WriteLine($"[ ] {currentOption}"); - } - } - } - - /// - /// Runs the menu. - /// - /// An integer that represents the selected option. - public virtual int RunMenu() - { - ConsoleKey keyPressed = default; - while (!Program.CloseRequested && keyPressed is not ConsoleKey.Enter) - { - Console.Clear(); - DisplayMenu(); - Console.CursorVisible = false; - keyPressed = Console.ReadKey().Key; - switch (keyPressed) - { - case ConsoleKey.UpArrow: - SelectedIndex = SelectedIndex is 0 ? Options.Length - 1 : SelectedIndex - 1; - break; - case ConsoleKey.DownArrow: - SelectedIndex = SelectedIndex == Options.Length - 1 ? 0 : SelectedIndex + 1; - break; - case ConsoleKey.Escape: - Program.CloseRequested = true; - break; - } - } - return SelectedIndex; - } -} \ No newline at end of file diff --git a/Projects/Oligopoly/Program.cs b/Projects/Oligopoly/Program.cs index 165fa44b..4accfe31 100644 --- a/Projects/Oligopoly/Program.cs +++ b/Projects/Oligopoly/Program.cs @@ -1,6 +1,7 @@ using System; using System.Collections.Generic; using System.IO; +using System.Linq; using System.Reflection; using System.Text; using System.Text.Json; @@ -9,25 +10,28 @@ namespace Oligopoly; public class Program { - public static bool CloseRequested { get; set; } = false; - public static List Companies { get; private set; } = null!; - public static List Events { get; private set; } = null!; + private static bool CloseRequested { get; set; } = false; + private static List Companies { get; set; } = null!; + private static List Events { 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; public static void Main() { try { - Console.CursorVisible = false; - LoadEmbeddedResources(); - RunMainMenu(); + MainMenuScreen(); } finally { + Console.ResetColor(); Console.CursorVisible = true; } } - public static void LoadEmbeddedResources() + private static void LoadEmbeddedResources() { Assembly assembly = Assembly.GetExecutingAssembly(); { @@ -40,42 +44,34 @@ public static void LoadEmbeddedResources() } } - private static void RunMainMenu() + private static void MainMenuScreen() { - StringBuilder prompt = new(); - prompt.AppendLine(); - prompt.AppendLine(" ██████╗ ██╗ ██╗ ██████╗ ██████╗ ██████╗ ██████╗ ██╗ ██╗ ██╗"); - prompt.AppendLine(" ██╔═══██╗██║ ██║██╔════╝ ██╔═══██╗██╔══██╗██╔═══██╗██║ ╚██╗ ██╔╝"); - prompt.AppendLine(" ██║ ██║██║ ██║██║ ███╗██║ ██║██████╔╝██║ ██║██║ ╚████╔╝ "); - prompt.AppendLine(" ██║ ██║██║ ██║██║ ██║██║ ██║██╔═══╝ ██║ ██║██║ ╚██╔╝ "); - prompt.AppendLine(" ╚██████╔╝███████╗██║╚██████╔╝╚██████╔╝██║ ╚██████╔╝███████╗██║ "); - prompt.AppendLine(" ╚═════╝ ╚══════╝╚═╝ ╚═════╝ ╚═════╝ ╚═╝ ╚═════╝ ╚══════╝╚═╝ "); - prompt.AppendLine(); - prompt.Append("You can exit the game at any time by pressing ESCAPE."); - prompt.AppendLine(); - prompt.Append("Use up and down arrow keys and enter to select an option:"); - Menu mainMenu = new(prompt.ToString(), - new string[] - { - "Play", - "About", - "Exit" - }); - while (!CloseRequested) { - int selectedOption = mainMenu.RunMenu(); - switch (selectedOption) + StringBuilder prompt = new(); + prompt.AppendLine(); + prompt.AppendLine(" ██████╗ ██╗ ██╗ ██████╗ ██████╗ ██████╗ ██████╗ ██╗ ██╗ ██╗"); + prompt.AppendLine(" ██╔═══██╗██║ ██║██╔════╝ ██╔═══██╗██╔══██╗██╔═══██╗██║ ╚██╗ ██╔╝"); + prompt.AppendLine(" ██║ ██║██║ ██║██║ ███╗██║ ██║██████╔╝██║ ██║██║ ╚████╔╝ "); + prompt.AppendLine(" ██║ ██║██║ ██║██║ ██║██║ ██║██╔═══╝ ██║ ██║██║ ╚██╔╝ "); + prompt.AppendLine(" ╚██████╔╝███████╗██║╚██████╔╝╚██████╔╝██║ ╚██████╔╝███████╗██║ "); + prompt.AppendLine(" ╚═════╝ ╚══════╝╚═╝ ╚═════╝ ╚═════╝ ╚═╝ ╚═════╝ ╚══════╝╚═╝ "); + prompt.AppendLine(); + prompt.Append("You can exit the game at any time by pressing ESCAPE."); + prompt.AppendLine(); + prompt.Append("Use up and down arrow keys and enter to select an option:"); + int selectedIndex = HandleMenuWithOptions(prompt.ToString(), + new string[] + { + "Play", + "About", + "Exit", + }); + switch (selectedIndex) { - case 0: - RunStartMenu(); - break; - case 1: - DisplayAboutInfo(); - break; - case 2: - CloseRequested = true; - break; + case 0: IntroductionScreen(); break; + case 1: AboutInfoScreen(); break; + case 2: CloseRequested = true; break; } } Console.Clear(); @@ -84,237 +80,356 @@ private static void RunMainMenu() Console.ReadKey(true); } - private static void RunStartMenu() + private static void InitializeGame() { - 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("Press any key to continue..."); - Console.CursorVisible = false; - CloseRequested = CloseRequested || Console.ReadKey(true).Key is ConsoleKey.Escape; - RunGameMenu(); + Money = 10000.00m; + LoadEmbeddedResources(); } - private static void RunGameMenu() + private static void GameLoop() { - double money = 10000; - bool isGameEnded = false; - Random random = new(); - - // Start of the game cycle. - while (!CloseRequested && !isGameEnded) + while (!CloseRequested) { - int currentEvent = random.Next(0, Events.Count); - - if (Events[currentEvent].Type is "Positive") - { - foreach (Company currentCompany in Companies) - { - if (currentCompany.Name == Events[currentEvent].CompanyName) - { - currentCompany.SharePrice = Math.Round(currentCompany.SharePrice + currentCompany.SharePrice * Events[currentEvent].Effect / 100, 2); - } - } - } - else if (Events[currentEvent].Type is "Negative") - { - foreach (Company currentCompany in Companies) - { - if (currentCompany.Name == Events[currentEvent].CompanyName) - { - currentCompany.SharePrice = Math.Round(currentCompany.SharePrice - currentCompany.SharePrice * Events[currentEvent].Effect / 100, 2); - } - } - } - - string prompt = "Use up and down arrow keys and enter to select an option:"; - string[] options = { "Skip", "Buy", "Sell", "More About Companies" }; - GameMenu gameMenu = new(prompt, options, currentEvent, money); - int selectedOption = -1; while (!CloseRequested && selectedOption is not 0) { - selectedOption = gameMenu.RunMenu(); + StringBuilder prompt = RenderCompanyStocksTable(); + prompt.AppendLine(); + prompt.Append("Use up and down arrow keys and enter to select an option:"); + selectedOption = HandleMenuWithOptions(prompt.ToString(), new string[] + { + "Wait For Market Change", + "Buy", + "Sell", + "Information About Companies", + }); switch (selectedOption) { - case 1: - RunActionMenu(ref money, currentEvent, true); - break; - case 2: - RunActionMenu(ref money, currentEvent, false); - break; - case 3: - DisplayMoreAboutCompaniesMenu(); - break; + case 1: BuyOrSellStockScreen(true); break; + case 2: BuyOrSellStockScreen(false); break; + case 3: CompanyDetailsScreen(); break; } } - // Check for win or loss. - if (money <= 0) - { - isGameEnded = true; - RunEndMenu(false); - } - else if (money >= 50000) + EventScreen(); + + switch (CalculateNetWorth()) { - isGameEnded = true; - RunEndMenu(true); + case >= WinningNetWorth: PlayerWinsScreen(); return; + case <= LosingNetWorth: PlayerLosesScreen(); return; } } } - /// - /// Runs action menu, that is buying or selling menu. - /// - /// The amount of money that user currently has. - /// The index of current generated event. - /// Flag that determines the mode of the method. True - buying, false - selling. - private static void RunActionMenu(ref double money, int currentEvent, bool isBuying) + private static void EventScreen() { - string actionPrompt = "Select a company: \n"; - string amountPrompt = "Select an amount: \n"; - string[] actionOptions = new string[Companies.Count]; - string[] amountOptions = { "Increase (+)", "Decrease (-)", "Enter" }; + CurrentEvent = Events[Random.Shared.Next(0, Events.Count)]; - for (int i = 0; i < actionOptions.Length; i++) + foreach (Company currentCompany in Companies) { - actionOptions[i] = Companies[i].Name; + if (currentCompany.Name == CurrentEvent.CompanyName) + { + currentCompany.SharePrice += currentCompany.SharePrice * CurrentEvent.Effect / 100; + } } - GameMenu actionMenu = new(actionPrompt, actionOptions, currentEvent, money); - GameMenu amountMenu = new(amountPrompt, amountOptions, currentEvent, money); - - int selectedCompany = actionMenu.RunMenu(); - int amountOfShares = amountMenu.RunAmountMenu(); + StringBuilder prompt = RenderCompanyStocksTable(); + prompt.AppendLine(); + prompt.AppendLine($"{CurrentEvent.Title}"); + prompt.AppendLine(); + prompt.AppendLine($"{CurrentEvent.Description}"); + prompt.AppendLine(); + prompt.Append("Press any key to continue..."); + Console.Clear(); + Console.Write(prompt); + Console.CursorVisible = false; + CloseRequested = CloseRequested || Console.ReadKey(true).Key is ConsoleKey.Escape; + } - if (isBuying) + private static void BuyOrSellStockScreen(bool isBuying) + { + int[] numberOfShares = new int[Companies.Count]; + int index = 0; + ConsoleKey key = default; + while (!CloseRequested && key is not ConsoleKey.Enter) { - Companies[selectedCompany].ShareAmount += amountOfShares; - money -= amountOfShares * Companies[selectedCompany].SharePrice; + // calculate the current cost of the transaction + decimal cost = 0.00m; + for (int i = 0; i < Companies.Count; i++) + { + cost += numberOfShares[i] * Companies[i].SharePrice; + } - Console.WriteLine($"You have bought {amountOfShares} shares of {Companies[selectedCompany].Name} company."); - Console.WriteLine("Press any key to continue..."); - Console.CursorVisible = false; - CloseRequested = CloseRequested || Console.ReadKey(true).Key is ConsoleKey.Escape; + Console.Clear(); + Console.WriteLine(RenderCompanyStocksTable()); + Console.WriteLine(); + Console.WriteLine($"Use the arrow keys and enter to confirm how many shares to {(isBuying ? "buy" : "sell")}:"); + for (int i = 0; i < Companies.Count; i++) + { + if (i == index) + { + (Console.BackgroundColor, Console.ForegroundColor) = (Console.ForegroundColor, Console.BackgroundColor); + Console.WriteLine($" < {numberOfShares[i]}{(!isBuying ? $"/{Companies[index].NumberOfShares}" : "")} > {Companies[i].Name}"); + Console.ResetColor(); + } + else + { + Console.WriteLine($" {numberOfShares[i]}{(!isBuying ? $"/{Companies[index].NumberOfShares}" : "")} {Companies[i].Name}"); + } + } + Console.WriteLine(); + Console.WriteLine($"{(isBuying ? "Cost" : "Payout")}: {cost:C}"); + + key = Console.ReadKey(true).Key; + switch (key) + { + case ConsoleKey.Escape: CloseRequested = true; return; + case ConsoleKey.UpArrow: index = index is 0 ? Companies.Count - 1 : index - 1; break; + case ConsoleKey.DownArrow: index = index == Companies.Count - 1 ? 0 : index + 1; break; + case ConsoleKey.RightArrow: + if (isBuying) + { + if (cost + Companies[index].SharePrice <= Money) + { + numberOfShares[index]++; + } + } + else + { + if (numberOfShares[index] < Companies[index].NumberOfShares) + { + numberOfShares[index]++; + } + } + break; + case ConsoleKey.LeftArrow: + if (numberOfShares[index] > 0) + { + numberOfShares[index]--; + } + break; + + } } - else + + if (CloseRequested) { - if (amountOfShares <= Companies[selectedCompany].ShareAmount) - { - Companies[selectedCompany].ShareAmount -= amountOfShares; - money += amountOfShares * Companies[selectedCompany].SharePrice; + return; + } - Console.WriteLine($"You have sold {amountOfShares} shares of {Companies[selectedCompany].Name} company."); - Console.WriteLine("Press any key to continue..."); - Console.CursorVisible = false; - CloseRequested = CloseRequested || Console.ReadKey(true).Key is ConsoleKey.Escape; + if (isBuying) + { + for (int i = 0; i < Companies.Count; i++) + { + Money -= numberOfShares[i] * Companies[i].SharePrice; + Companies[i].NumberOfShares += numberOfShares[i]; } - else + } + else + { + for (int i = 0; i < Companies.Count; i++) { - Console.WriteLine("Entered not a valid value"); - Console.WriteLine("Press any key to continue..."); - Console.CursorVisible = false; - CloseRequested = CloseRequested || Console.ReadKey(true).Key is ConsoleKey.Escape; + Money += numberOfShares[i] * Companies[i].SharePrice; + Companies[i].NumberOfShares -= numberOfShares[i]; } } + + Console.Clear(); + Console.WriteLine(RenderCompanyStocksTable()); + Console.WriteLine($"You shares have been updated."); + Console.WriteLine(); + Console.Write("Press any key to continue..."); + Console.CursorVisible = false; + CloseRequested = CloseRequested || Console.ReadKey(true).Key is ConsoleKey.Escape; } - private static void DisplayMoreAboutCompaniesMenu() + private static void CompanyDetailsScreen() { Console.Clear(); foreach (Company company in Companies) { - Console.WriteLine($"{company.Name} - {company.Description}\n"); + Console.WriteLine($"{company.Name} - {company.Description}"); + Console.WriteLine(); } - Console.WriteLine("Press any key to exit the menu..."); + Console.Write("Press any key to exit the menu..."); + Console.CursorVisible = false; + CloseRequested = CloseRequested || Console.ReadKey(true).Key is ConsoleKey.Escape; + } + + 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.Write("Press any key to continue..."); Console.CursorVisible = false; CloseRequested = CloseRequested || Console.ReadKey(true).Key is ConsoleKey.Escape; + InitializeGame(); + GameLoop(); } - /// - /// Runs end menu. - /// - /// Flag that determines the mode of the method. True - for a winner, false - for a loser. - private static void RunEndMenu(bool isWinner) + private static void PlayerWinsScreen() { Console.Clear(); - if (isWinner) + 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.Write("Press any key (except ENTER) to continue..."); + ConsoleKey key = ConsoleKey.Enter; + while (!CloseRequested && key is ConsoleKey.Enter) { - 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("Press any key to continue..."); Console.CursorVisible = false; - CloseRequested = CloseRequested || Console.ReadKey(true).Key is ConsoleKey.Escape; + key = Console.ReadKey(true).Key; + CloseRequested = CloseRequested || key is ConsoleKey.Escape; } - else + } + + 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.Write("Press any key (except ENTER) to continue..."); + ConsoleKey key = ConsoleKey.Enter; + while (!CloseRequested && key is ConsoleKey.Enter) { - 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("Press any key to continue..."); Console.CursorVisible = false; - CloseRequested = CloseRequested || Console.ReadKey(true).Key is ConsoleKey.Escape; + key = Console.ReadKey(true).Key; + CloseRequested = CloseRequested || key is ConsoleKey.Escape; } } - private static void DisplayAboutInfo() + private static void AboutInfoScreen() { Console.Clear(); - 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(" | 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("Press any key to continue..."); Console.CursorVisible = false; CloseRequested = CloseRequested || Console.ReadKey(true).Key is ConsoleKey.Escape; } + + private static StringBuilder RenderCompanyStocksTable() + { + // table column widths + 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)}─╢"); + foreach (Company company in Companies) + { + 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}"); + return gameView; + } + + private static int HandleMenuWithOptions(string prompt, string[] options) + { + int index = 0; + ConsoleKey key = default; + while (!CloseRequested && key is not ConsoleKey.Enter) + { + Console.Clear(); + Console.WriteLine(prompt); + 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.Escape: CloseRequested = true; break; + } + } + return index; + } + + private static decimal CalculateNetWorth() + { + decimal netWorth = Money; + foreach (Company company in Companies) + { + netWorth += company.SharePrice * company.NumberOfShares; + } + return netWorth; + } } \ No newline at end of file diff --git a/Projects/Oligopoly/README.md b/Projects/Oligopoly/README.md index ca003f32..1055d6ce 100644 --- a/Projects/Oligopoly/README.md +++ b/Projects/Oligopoly/README.md @@ -21,11 +21,30 @@ > **Note** This game was a *[Community Contribution](https://github.com/dotnet/dotnet-console-games/pull/72)! -Oligopoly is a stock market betting game. Buy stocks in a company and then try to sell them at a higher price. +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 + +Use up and down arrow keys and enter to select an option: +[*] Wait For Market Change +[ ] Buy +[ ] Sell +[ ] Information About Companies +``` ## Input -- `↑`, `↓`: menu selection +- `↑`, `↓`, `←`, `→`: menu selection - `enter`: confirm - `escape`: exit game diff --git a/Projects/Website/Company.json b/Projects/Website/Company.json new file mode 100644 index 00000000..5ab373d6 --- /dev/null +++ b/Projects/Website/Company.json @@ -0,0 +1,38 @@ +[ + { + "Name": "Bingoo", + "Industry": "Web", + "SharePrice": 1500, + "NumberOfShares": 0, + "Description": "Promising search company. Leader in the development of various web services and web applications. Bingoo is known for its innovative and user-friendly products that aim to make the web more accessible and enjoyable. Bingoo also invests in artificial intelligence and machine learning to enhance its search engine and other services." + }, + { + "Name": "Quantum Software", + "Industry": "Software", + "SharePrice": 2000, + "NumberOfShares": 0, + "Description": "Software development company. The company is best known for its own operating system and various software packages. Quantum Software is a pioneer in the field of software engineering and has a reputation for creating reliable and fast products. Quantum Software also collaborates with other companies and organizations to provide customized solutions for their needs." + }, + { + "Name": "Edison Incorporated", + "Industry": "Energy", + "SharePrice": 1000, + "NumberOfShares": 0, + "Description": "An innovative company engaged in the development and production of electric vehicles, batteries, solar panels. Edison Incorporated is a leader in the green energy sector and strives to reduce the environmental impact of transportation and energy consumption. Edison Incorporated also offers a range of services and products for consumers and businesses who want to switch to renewable energy sources." + }, + { + "Name": "Netfilm", + "Ticker": "NTF", + "Industry": "Movies", + "SharePrice": 800, + "NumberOfShares": 0, + "Description": "A leading company in the field of online movies and series, also engaged in the development of video hosting. Netfilm is a popular platform for streaming and watching movies and series of various genres and languages. Netfilm also produces its own original content that attracts millions of viewers. Netfilm also provides a video hosting service that allows users to upload and share their own videos." + }, + { + "Name": "COBRA Security Consulting", + "Industry": "Army", + "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." + } +] \ No newline at end of file diff --git a/Projects/Website/Event.json b/Projects/Website/Event.json new file mode 100644 index 00000000..867aeb5d --- /dev/null +++ b/Projects/Website/Event.json @@ -0,0 +1,302 @@ +[ + { + "Title": "Bingoo announcing their new search engine", + "Description": "The company has announced its new search engine that will be more productive and user-friendly than the previous one. The search engine also uses artificial intelligence technology to improve search results and provide personalized recommendations to users. Experts predict that this will increase the value of the company\u2019s shares and attract more customers to its products and services.", + "CompanyName": "Bingoo", + "Effect": 15 + }, + { + "Title": "Bingoo announcing their new AI assistant", + "Description": "Bingoo has unveiled its latest innovation: Bingy. An AI assistant that can chat, search, and create content for users. Bingy is powered by advanced natural language processing and machine learning technologies that enable it to understand and communicate fluently in multiple languages. Bingy is available as an application that users can install on their computers or phones for easy and convenient access.", + "CompanyName": "Bingoo", + "Effect": 10 + }, + { + "Title": "Bingoo introduces new features and improvements for its web services", + "Description": "Bingoo has introduced a series of new features and improvements for its web services. The new features include voice search, image recognition, personalized recommendations, smart suggestions, faster loading times, better security and more. The updates apply to Bingoo\u0027s popular web services such as Bingoo Mail, Bingoo Cloud, Bingoo Maps, Bingoo News and others.", + "CompanyName": "Bingoo", + "Effect": 5 + }, + { + "Title": "Bingoo creates a special event to attract more web developers", + "Description": "The event, called Bingoo Webathon, is a 24-hour online marathon of web development challenges, tutorials, demos and prizes. Bingoo said that the event is designed to showcase its web services and web applications and to inspire and motivate web developers of all levels and backgrounds to join its community and platform. ", + "CompanyName": "Bingoo", + "Effect": 5 + }, + { + "Title": "Bingoo wins industry award for innovative web services", + "Description": "Bingoo has won an industry award for its innovative and user-friendly web services, including its search engine and web applications. The award recognizes Bingoo\u0027s commitment to providing the best possible user experiences and staying at the forefront of technology trends.", + "CompanyName": "Bingoo", + "Effect": 5 + }, + { + "Title": "Bingoo was accused of violating user privacy", + "Description": "The company was accused of stealing the personal data of its users and selling it to third parties without their consent. The case is currently under investigation by the authorities, but experts believe that this scandal will harm the company and its reputation. The company may face legal consequences and lose the trust of its users.", + "CompanyName": "Bingoo", + "Effect": -15 + }, + { + "Title": "Bingoo\u0027s servers experience a service outage", + "Description": "Bingoo\u0027s services have been down for several hours due to a technical issue. Users have been unable to access their accounts, send emails, or use other Bingoo services during this time. The company has released a statement apologizing for the inconvenience and stating that it is working to resolve the issue as soon as possible.", + "CompanyName": "Bingoo", + "Effect": -10 + }, + { + "Title": "Bingoo missed out on a lucrative acquisition deal", + "Description": "Bingoo was in talks to acquire a promising startup that could have helped the company expand its services and increase its market share. However, the company\u0027s management decided to abandon the deal at the last minute, citing concerns about the startup\u0027s financial health and market potential. This decision was criticized by shareholders and industry experts, who believe that Bingoo missed a valuable opportunity to grow its business and compete with its rivals.", + "CompanyName": "Bingoo", + "Effect": -5 + }, + { + "Title": "Bingoo criticized for excessive advertising in its products", + "Description": "Bingoo has been heavily criticized by its users for the excessive amount of ads present in its search engine. Many users have complained that the ads are intrusive and negatively affect their experience with the product. This has led to a decrease in user satisfaction and may ultimately lead to a decrease in sales.", + "CompanyName": "Bingoo", + "Effect": -5 + }, + { + "Title": "Bingoo terminates partnerships with phone manufacturers", + "Description": "Bingoo has announced that it will no longer be partnering with phone manufacturers to pre-install its search engine on their devices. This decision has been met with disappointment from phone manufacturers, as Bingoo\u0027s search engine is a popular choice among users. The move may lead to a decrease in Bingoo\u0027s market share and revenue, as users may choose other search engines instead.", + "CompanyName": "Bingoo", + "Effect": -5 + }, + { + "Title": "Quantum Software announces new operating system", + "Description": "The company has introduced its new operating system from the Qore OS family at a presentation event. The company claims that the new operating system is more reliable and faster than the competitors\u2019 ones. The new operating system also has new features and functions that enhance the user experience. Experts expect the company\u2019s share price to rise and the new operating system to become popular among users.", + "CompanyName": "Quantum Software", + "Effect": 15 + }, + { + "Title": "Quantum Software announces update for Quantum Workflow", + "Description": "Quantum Software has just announced an exciting new update for its popular software package - Quantum Workflow. This new version is packed with innovative features and improvements that are sure to streamline your workflow and boost productivity. With its user-friendly interface and powerful capabilities, Quantum Workflow has already become a favorite among professionals in a variety of industries.", + "CompanyName": "Quantum Software", + "Effect": 10 + }, + { + "Title": "Quantum Software presents its new development kit", + "Description": "The company has inoduced its new update for software development kit (QSDK). The new QSDK includes a powerful quantum simulator, a comprehensive set of libraries and frameworks, and a user-friendly development environment that makes it easy to get started with quantum programming. With QSDK developers also have access to new documnetation (QSDN), which will help them build robust and scalable applications.", + "CompanyName": "Quantum Software", + "Effect": 5 + }, + { + "Title": "Quantum Software acquires a promising company", + "Description": "Quantum Software management has confirmed the purchase of a small software company. According to the company\u0027s management, the deal turned out to be very beneficial for both parties. The new software will soon be available on Quore OS operating systems and the company expects sales to increase in the near future.", + "CompanyName": "Quantum Software", + "Effect": 5 + }, + { + "Title": "Quantum Software invests in Quantum Sky development", + "Description": "Quantum Software announced a major investment in the development of Quantum Sky, its cloud platform and infrastructure for creating innovative solutions in artificial intelligence, big data and internet of things. Quantum Sky aims to provide customers with access to the most advanced quantum computing resources and services, as well as to foster collaboration and innovation among researchers, developers and entrepreneurs. Quantum Software expects that Quantum Sky will boost its revenue and market share", + "CompanyName": "Quantum Software", + "Effect": 5 + }, + { + "Title": "The Antimonopoly Commission accused Quantum Software of illegally maintaining its monopoly position", + "Description": "The Antimonopoly Commission announced that it has launched an investigation into Quantum Software. The commission claims that Quantum Software has abused its dominant position by engaging in unfair practices such as predatory pricing, exclusive contracts, and bundling products. The commission said that these practices have harmed consumers and competitors, and stifled innovation in the software market. The company said that it operates in a highly competitive and dynamic environment, and that its success is based on its superior products and services.", + "CompanyName": "Quantum Software", + "Effect": -15 + }, + { + "Title": "Quantum Software reported a data breach", + "Description": "Some of the company\u2019s servers were hacked by unknown attackers. The company is working with the police on this matter, but it is already known that their development of an unreleased operating system was stolen. The stolen data may contain sensitive information and secrets that could damage the company\u2019s business. The company may also face legal action from its partners and customers who were affected by the breach.", + "CompanyName": "Quantum Software", + "Effect": -10 + }, + { + "Title": "Users are unhappy with the latest Quore OS update", + "Description": "The latest update of Quore OS leads to numerous system breakdowns, and in some cases, loss of user data. Quantum Software has already apologized for the inconvenience and is working to remedy the situation. However, this event has caused many to consider alternative products, which could lead to a decrease in sales of Quantum Software.", + "CompanyName": "Quantum Software", + "Effect": -5 + }, + { + "Title": "Quantum Software breaks partnership with driver manufacturer", + "Description": "Quantum Software management announced the termination of cooperation with one of the largest manufacturers of drivers for their systems. The reasons for this abrupt decision are not clear. The company said it is looking into alternative solutions to this problem. However, this may cause their operating systems to fall behind technically and reduce profits.", + "CompanyName": "Quantum Software", + "Effect": -5 + }, + { + "Title": "Quantum Software faced mass layoffs", + "Description": "The company is facing massive layoffs. Employees say that before the release of the next major update, management began to set impossible tasks for them and give them the shortest possible time. The company\u0027s management has not yet commented on this, but this news will definitely not benefit the company\u0027s share prices.", + "CompanyName": "Quantum Software", + "Effect": -5 + }, + { + "Title": "Edison Incorporated presents its new electric car", + "Description": "The company\u2019s new electric cars with autopilot function went on sale in several countries. Edison Incorporated has managed to reduce the charging time of the car and increase its battery life by using innovative technology and materials. The first owners of electric cars are already leaving positive reviews and praising the performance and design of the car. The company expects to increase its sales and market share in the electric vehicle industry.", + "CompanyName": "Edison Incorporated", + "Effect": 15 + }, + { + "Title": "Edison Incorporated enters the Asian market", + "Description": "The company has announced that it will start selling its electric vehicles in several Asian countries, including China, Japan, and India. The company said that it sees a huge potential for growth in these markets, as the demand for green and smart transportation is increasing. Edison Incorporated expects that this move will boost its sales and revenue, as well as its brand recognition and reputation.", + "CompanyName": "Edison Incorporated", + "Effect": 10 + }, + { + "Title": "Edison Incorporated launches a successful advertising campaign", + "Description": "The company has launched a new advertising campaign to promote its electric vehicles and solar panels. The campaign features celebrities, influencers, and ordinary people who share their positive experiences with the company\u2019s products and services. The campaign also highlights the environmental and economic benefits of switching to renewable energy sources. The campaign has received a lot of positive feedback and attention from the public and the media, and has increased the company\u2019s popularity and customer loyalty.", + "CompanyName": "Edison Incorporated", + "Effect": 5 + }, + { + "Title": "Edison Incorporated develops a more efficient electric engine", + "Description": "Edison Incorporated has developed a new electric engine that is more efficient and powerful than its previous models. The new engine uses less energy and produces less noise and emissions. The company said that the new engine will improve the performance and range of its electric vehicles, as well as reduce the maintenance costs and carbon footprint. The company plans to implement the new engine in its upcoming models and offer it as an upgrade option for existing customers. ", + "CompanyName": "Edison Incorporated", + "Effect": 5 + }, + { + "Title": "Edison Incorporated reduces the prices of its products", + "Description": "The company has announced that it will reduce the prices of its electric vehicles and solar panels by 10%. Edison Incorporated said that this decision is motivated by its desire to make its products more affordable and accessible to a wider range of customers. The company also said that it has achieved significant cost reductions thanks to its technological innovations and economies of scale. The price reduction is expected to increase the demand and sales of the company\u2019s products, as well as its market share and competitiveness.", + "CompanyName": "Edison Incorporated", + "Effect": 5 + }, + { + "Title": "Edison Incorporated is facing production difficulties", + "Description": "The company said it was having difficulty mining lithium, which is a key material for producing batteries for electric vehicles. The company blamed the shortage of lithium on environmental issues and political instability in some regions. Edison Incorporated assures that the difficulties are temporary and that it is looking for alternative sources of lithium. But we can already say that they harmed the company\u2019s production and profits.", + "CompanyName": "Edison Incorporated", + "Effect": -15 + }, + { + "Title": "Edison Incorporated recalls some of its electric vehicles ", + "Description": "Edison Incorporated has announced that it will recall some of its electric vehicles due to a defect in the battery system that could cause overheating and fire. The company said that the recall affects a small percentage of its vehicles and that it will provide free repairs and replacements to the affected customers. The company apologized for the inconvenience and said that it is taking all the necessary measures to ensure the safety and quality of its products. However, this incident has damaged the company\u2019s reputation and customer confidence.", + "CompanyName": "Edison Incorporated", + "Effect": -10 + }, + { + "Title": "Edison Incorporated faces increased competition in the electric vehicle market", + "Description": "The company faces increased competition from other companies that are also producing and selling electric vehicles. Some of these competitors offer similar or better products at lower prices or with more features and options. The company said that it is confident in its products and services and that it will continue to innovate and improve its offerings. However, this may affect the company\u2019s sales and market share, as customers may choose other alternatives. ", + "CompanyName": "Edison Incorporated", + "Effect": -5 + }, + { + "Title": "Customers criticize Edison Incorporated", + "Description": "The company has received some criticism from its customers who are unhappy with some aspects of its products and services. The customers have complained about the high prices, long delivery times, and poor customer service of the company. The company has responded to the criticism by acknowledging the issues and promising to improve its performance and quality. Edison Incorporated said that it values its customers\u2019 feedback and that it will use it to enhance its products and services. The company hopes that this will restore its customer trust and satisfaction.", + "CompanyName": "Edison Incorporated", + "Effect": -5 + }, + { + "Title": "Edison Incorporated reports problems with its autopilot system", + "Description": "The company has reported that some of its electric vehicles have experienced problems with their autopilot system. The system is supposed to assist the driver in steering, braking, and changing lanes, but some customers have reported that it has malfunctioned or failed to respond in some situations. Edison Incorporated said that it is investigating the cause of the problems and that it will issue a software update to fix them. The company also advised its customers to always pay attention and be ready to take over the control of the vehicle when using the autopilot system. The problems have raised some safety and reliability concerns among the customers and the regulators.", + "CompanyName": "Edison Incorporated", + "Effect": -5 + }, + { + "Title": "Netfilm announces new series", + "Description": "The company has confirmed the creation of its new series, which will be exclusive to its platform. The title and plot are still unknown, but the public already looks interested and curious. The company said that the new series will be a high-quality production with a talented cast and crew. The company hopes that the new series will attract more subscribers and viewers to its platform.", + "CompanyName": "Netfilm", + "Effect": 15 + }, + { + "Title": "Netfilm wins awards for its original content", + "Description": "The company has won several awards for its original content, including movies and series. The awards recognize Netfilm\u2019s creativity and excellence in producing and streaming high-quality content that appeals to a wide audience. The awards also boost Netfilm\u2019s reputation and popularity in the online streaming industry.", + "CompanyName": "Netfilm", + "Effect": 10 + }, + { + "Title": "Netfilm improves its video hosting service", + "Description": "Netfilm has announced that it has improved its video hosting service, which allows users to upload and stream their own videos on its platform. The company said that the improvement will enhance the quality, speed, and security of the video hosting service, as well as provide more options and features for users. The company said that the improvement will attract more users and creators to its platform, and increase its revenue and profit.", + "CompanyName": "Netfilm", + "Effect": 5 + }, + { + "Title": "Netfilm offers a subscription discount", + "Description": "Netfilm has announced that it will offer a subscription discount for its customers who sign up for a year or more. The company said that the discount will make its service more affordable and accessible for its customers, as well as increase its customer loyalty and retention. The company said that the discount is part of its customer appreciation and promotion campaign.", + "CompanyName": "Netfilm", + "Effect": 5 + }, + { + "Title": "Netfilm rewards its loyal customers", + "Description": "Netfilm has announced that it has rewarded its loyal customers with special offers and benefits. The company said that it has launched a loyalty program that allows its customers to earn points and redeem them for discounts, free trials, or exclusive content. The company also said that it has sent personalized recommendations and gifts to its customers, based on their preferences and interests.", + "CompanyName": "Netfilm", + "Effect": 5 + }, + { + "Title": "Netfilm faced lawsuit", + "Description": "Netfilm sued by movie studios for streaming their content without permission. Netfilm denies the charges and says it has a fair use policy that allows it to stream content for educational and entertainment purposes. The lawsuit could affect the online streaming industry and set a precedent for future cases. The company may have to pay a large amount of money in damages or remove some content from its platform.", + "CompanyName": "Netfilm", + "Effect": -15 + }, + { + "Title": "Netfilm delays new releases", + "Description": "Netfilm has announced that it will delay some of its new releases, due to production difficulties or quality issues. The company said that it wants to ensure that its new releases meet its high standards and expectations, and that it apologizes for any inconvenience caused to its customers. However, this decision has disappointed some of its customers who were eagerly waiting for the new releases, and has given an advantage to its competitors who have released their content on time.", + "CompanyName": "Netfilm", + "Effect": -10 + }, + { + "Title": "Netfilm faces controversy over its content", + "Description": "Netfilm has faced controversy over some of its content, which has been accused of being offensive, inappropriate, or inaccurate. Some of its content has sparked backlash and criticism from various groups and individuals, who have demanded that Netfilm remove or apologize for the content. Some of its content has also been banned or censored in some countries or regions, due to legal or cultural reasons. This controversy has harmed Netfilm\u2019s image and reputation, as well as caused some of its customers and partners to boycott or cancel its service.", + "CompanyName": "Netfilm", + "Effect": -5 + }, + { + "Title": "Netfilm faces piracy threat", + "Description": "Netfilm has faced piracy threat, which has affected its revenue and profit. The company has discovered that some of its content has been illegally copied or distributed by unauthorized parties or platforms. The company has also found that some of its customers have shared their accounts or passwords with others, who have accessed its service without paying. The company said that it is taking measures to protect its intellectual property rights and to prevent piracy. However, this situation has reduced Netfilm\u2019s income and market share, as well as damaged its exclusivity and value.", + "CompanyName": "Netfilm", + "Effect": -5 + }, + { + "Title": "Netfilm faces employee strike", + "Description": "Netfilm has faced employee strike, which has disrupted its operations and productivity. The company\u2019s employees have gone on strike to demand better working conditions, wages, and benefits. The company said that it is negotiating with the employees and their representatives, and that it hopes to reach a fair and reasonable agreement. However, this situation has affected Netfilm\u2019s performance and output, as well as its relationship and trust with its employees.", + "CompanyName": "Netfilm", + "Effect": -5 + }, + { + "Title": "COBRA Security Consulting signs a contract with the government", + "Description": "The company signed a contract with the government to ensure the security of state facilities such as military bases, power plants, airports, etc. COBRA operatives are already arriving at the facilities and setting up security measures. The exact amount of the contract was not disclosed, but it is already clear that the contract is beneficial to both parties. The contract will provide a stable income for the company and enhance the security of the state facilities.", + "CompanyName": "COBRA Security Consulting", + "Effect": 15 + }, + { + "Title": "The United Nations gives permission for COBRA Security Consulting to operate in new territories", + "Description": "The United Nations has granted permission for COBRA Security Consulting to operate in new territories that are under its supervision and protection. The permission allows the company to provide security services and solutions to various clients and sectors in these territories, such as humanitarian organizations, businesses, and governments. The company said that the permission is a sign of its credibility and reputation, as well as an opportunity to expand its scope and impact.", + "CompanyName": "COBRA Security Consulting", + "Effect": 10 + }, + { + "Title": "COBRA Security Consulting successfully completes the rescue operation", + "Description": "COBRA Security Consulting announced that it has successfully completed the rescue operation of a group of hostages held by a terrorist organization in a remote location. The operation involved a team of highly trained and experienced operatives who infiltrated the enemy camp and freed the hostages without any casualties. The hostages were then transported to a safe place and reunited with their families. The company said that the operation was a testament to its skills and dedication to saving lives.", + "CompanyName": "COBRA Security Consulting", + "Effect": 5 + }, + { + "Title": "COBRA Security Consulting unveils its new technology and equipment", + "Description": "COBRA Security Consulting unveils its new technology and equipment for its operatives. The new technology and equipment include advanced drones, sensors, weapons, and communication devices that enhance the capabilities and safety of its operatives. The company said that the new technology and equipment will give it an edge over its competitors and adversaries", + "CompanyName": "COBRA Security Consulting", + "Effect": 5 + }, + { + "Title": "COBRA Security Consulting secures a supply contract with government", + "Description": "COBRA Security Consulting revealed that it has provided security supplies to the government as part of a contract to equip its forces and agencies with the latest security equipment and technology. The contract will enhance the company\u2019s revenue and reputation, as well as show its competence and dependability of its products and services. The company said that the contract is an acknowledgment of its innovation and excellence, and that it is pleased and honored to collaborate with the government.", + "CompanyName": "COBRA Security Consulting", + "Effect": 5 + }, + { + "Title": "COBRA Security Consulting is being criticized for their violent actions", + "Description": "COBRA Security Consulting has been criticized for its harsh actions in the Middle East on the territory of the facilities under its protection. The company\u2019s management states that this is necessary to ensure security in the region and prevent terrorist attacks. However, some human rights organizations and media outlets accuse the company of using excessive force and violating international law. Government has already become interested in this case, and most likely the company will face punishment such as sanctions, fines, or termination of contracts.", + "CompanyName": "COBRA Security Consulting", + "Effect": -15 + }, + { + "Title": "COBRA Security Consulting brigades were captured", + "Description": "COBRA Security Consulting confirmed that some of its brigades were captured by a rebel group during a security operation. The brigades were part of a team that was providing security and escort to a convoy of humanitarian aid workers who were delivering supplies to a war-torn area. The rebel group ambushed the convoy and took the brigades as hostages. The company said that it is in contact with the rebel group and is negotiating for the release of the brigades. The company also said that it is doing everything in its power to ensure the safety and well-being of its brigades.", + "CompanyName": "COBRA Security Consulting", + "Effect": -10 + }, + { + "Title": "Fighter of COBRA Security Consulting was shot down", + "Description": "COBRA Security Consulting confirmed that one of its fighters was shot down by an unknown enemy during a security mission. The fighter was part of a team that was providing air support to a client who was under attack by a hostile force. The fighter was hit by a missile and crashed in a remote area. The company said that it is trying to locate and rescue the pilot, who is presumed to be alive. The company also said that it is investigating the identity and motive of the enemy who shot down the fighter.", + "CompanyName": "COBRA Security Consulting", + "Effect": -5 + }, + { + "Title": "COBRA Security Consulting vehicle involved in a deadly accident", + "Description": "A COBRA Security Consulting vehicle has been involved in a serious accident that resulted in several casualties, including civilians and company personnel. The accident happened during a convoy operation, and the cause of the accident is still under investigation. The company is offering support and compensation to the victims and their families, but it may face legal action and reputational damage from the incident.", + "CompanyName": "COBRA Security Consulting", + "Effect": -5 + }, + { + "Title": "COBRA Security Consulting staff arrested for illegal activity", + "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 + } +] \ No newline at end of file diff --git a/Projects/Website/Games/Oligopoly/Company.cs b/Projects/Website/Games/Oligopoly/Company.cs new file mode 100644 index 00000000..a3dd629b --- /dev/null +++ b/Projects/Website/Games/Oligopoly/Company.cs @@ -0,0 +1,12 @@ +#nullable disable + +namespace Website.Games.Oligopoly; + +public class Company +{ + public string Name { get; set; } + public string Industry { get; set; } + public decimal SharePrice { get; set; } + public int NumberOfShares { get; set; } + public string Description { get; set; } +} diff --git a/Projects/Website/Games/Oligopoly/Event.cs b/Projects/Website/Games/Oligopoly/Event.cs new file mode 100644 index 00000000..3c67600e --- /dev/null +++ b/Projects/Website/Games/Oligopoly/Event.cs @@ -0,0 +1,11 @@ +#nullable disable + +namespace Website.Games.Oligopoly; + +public class Event +{ + public string Title { get; set; } + public string Description { get; set; } + public string CompanyName { get; set; } + public int Effect { get; set; } +} diff --git a/Projects/Website/Games/Oligopoly/Oligopoly.cs b/Projects/Website/Games/Oligopoly/Oligopoly.cs new file mode 100644 index 00000000..063315ff --- /dev/null +++ b/Projects/Website/Games/Oligopoly/Oligopoly.cs @@ -0,0 +1,435 @@ +using System; +using System.Threading.Tasks; +using System.Linq; +using System.Collections.Generic; +using System.Text; +using System.Text.Json; + +namespace Website.Games.Oligopoly; + +public class Oligopoly +{ + public readonly BlazorConsole Console = new(); + + public async Task Run() + { + bool CloseRequested = false; +#pragma warning disable IDE0059 // Unnecessary assignment of a value + List Companies = null!; + List Events = null!; + Event CurrentEvent = null!; + decimal Money = 10000.00m; +#pragma warning restore IDE0059 // Unnecessary assignment of a value + const decimal LosingNetWorth = 2000.00m; + const decimal WinningNetWorth = 50000.00m; + + try + { + await MainMenuScreen(); + } + finally + { + Console.ResetColor(); + Console.CursorVisible = true; + } + + void LoadEmbeddedResources() + { + Companies = JsonSerializer.Deserialize>(Resources.Company_json!)!; + Events = JsonSerializer.Deserialize>(Resources.Event_json!)!; + } + + async Task MainMenuScreen() + { + while (!CloseRequested) + { + StringBuilder prompt = new(); + prompt.AppendLine(); + prompt.AppendLine(" ██████╗ ██╗ ██╗ ██████╗ ██████╗ ██████╗ ██████╗ ██╗ ██╗ ██╗"); + prompt.AppendLine(" ██╔═══██╗██║ ██║██╔════╝ ██╔═══██╗██╔══██╗██╔═══██╗██║ ╚██╗ ██╔╝"); + prompt.AppendLine(" ██║ ██║██║ ██║██║ ███╗██║ ██║██████╔╝██║ ██║██║ ╚████╔╝ "); + prompt.AppendLine(" ██║ ██║██║ ██║██║ ██║██║ ██║██╔═══╝ ██║ ██║██║ ╚██╔╝ "); + prompt.AppendLine(" ╚██████╔╝███████╗██║╚██████╔╝╚██████╔╝██║ ╚██████╔╝███████╗██║ "); + prompt.AppendLine(" ╚═════╝ ╚══════╝╚═╝ ╚═════╝ ╚═════╝ ╚═╝ ╚═════╝ ╚══════╝╚═╝ "); + prompt.AppendLine(); + prompt.Append("You can exit the game at any time by pressing ESCAPE."); + prompt.AppendLine(); + prompt.Append("Use up and down arrow keys and enter to select an option:"); + int selectedIndex = await HandleMenuWithOptions(prompt.ToString(), + new string[] + { + "Play", + "About", + "Exit", + }); + switch (selectedIndex) + { + case 0: await IntroductionScreen(); break; + case 1: await AboutInfoScreen(); break; + case 2: CloseRequested = true; break; + } + } + await Console.Clear(); + await Console.WriteLine("Oligopoly was closed. Press any key to continue..."); + Console.CursorVisible = false; + await Console.ReadKey(true); + } + + async Task InitializeGame() + { + await Console.Clear(); + await Console.Write("loading..."); + await Console.Refresh(); + + Money = 10000.00m; + LoadEmbeddedResources(); + } + + async Task GameLoop() + { + while (!CloseRequested) + { + int selectedOption = -1; + while (!CloseRequested && selectedOption is not 0) + { + StringBuilder prompt = RenderCompanyStocksTable(); + prompt.AppendLine(); + prompt.Append("Use up and down arrow keys and enter to select an option:"); + selectedOption = await HandleMenuWithOptions(prompt.ToString(), new string[] + { + "Wait For Market Change", + "Buy", + "Sell", + "Information About Companies", + }); + switch (selectedOption) + { + case 1: await BuyOrSellStockScreen(true); break; + case 2: await BuyOrSellStockScreen(false); break; + case 3: await CompanyDetailsScreen(); break; + } + } + + await EventScreen(); + + switch (CalculateNetWorth()) + { + case >= WinningNetWorth: await PlayerWinsScreen(); return; + case <= LosingNetWorth: await PlayerLosesScreen(); return; + } + } + } + + async Task EventScreen() + { + 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; + } + } + + StringBuilder prompt = RenderCompanyStocksTable(); + prompt.AppendLine(); + prompt.AppendLine($"{CurrentEvent.Title}"); + prompt.AppendLine(); + prompt.AppendLine($"{CurrentEvent.Description}"); + prompt.AppendLine(); + prompt.Append("Press any key to continue..."); + await Console.Clear(); + await Console.Write(prompt); + Console.CursorVisible = false; + CloseRequested = CloseRequested || (await Console.ReadKey(true)).Key is ConsoleKey.Escape; + } + + async Task BuyOrSellStockScreen(bool isBuying) + { + int[] numberOfShares = new int[Companies.Count]; + int index = 0; + ConsoleKey key = default; + while (!CloseRequested && key is not ConsoleKey.Enter) + { + // calculate the current cost of the transaction + decimal cost = 0.00m; + for (int i = 0; i < Companies.Count; i++) + { + cost += numberOfShares[i] * Companies[i].SharePrice; + } + + await Console.Clear(); + await Console.WriteLine(RenderCompanyStocksTable()); + await Console.WriteLine(); + await Console.WriteLine($"Use the arrow keys and enter to confirm how many shares to {(isBuying ? "buy" : "sell")}:"); + for (int i = 0; i < Companies.Count; i++) + { + if (i == index) + { + (Console.BackgroundColor, Console.ForegroundColor) = (Console.ForegroundColor, Console.BackgroundColor); + await Console.WriteLine($" < {numberOfShares[i]}{(!isBuying ? $"/{Companies[index].NumberOfShares}" : "")} > {Companies[i].Name}"); + Console.ResetColor(); + } + else + { + await Console.WriteLine($" {numberOfShares[i]}{(!isBuying ? $"/{Companies[index].NumberOfShares}" : "")} {Companies[i].Name}"); + } + } + await Console.WriteLine(); + await Console.WriteLine($"{(isBuying ? "Cost" : "Payout")}: {cost:C}"); + + key = (await Console.ReadKey(true)).Key; + switch (key) + { + case ConsoleKey.Escape: CloseRequested = true; return; + case ConsoleKey.UpArrow: index = index is 0 ? Companies.Count - 1 : index - 1; break; + case ConsoleKey.DownArrow: index = index == Companies.Count - 1 ? 0 : index + 1; break; + case ConsoleKey.RightArrow: + if (isBuying) + { + if (cost + Companies[index].SharePrice <= Money) + { + numberOfShares[index]++; + } + } + else + { + if (numberOfShares[index] < Companies[index].NumberOfShares) + { + numberOfShares[index]++; + } + } + break; + case ConsoleKey.LeftArrow: + if (numberOfShares[index] > 0) + { + numberOfShares[index]--; + } + break; + + } + } + + if (CloseRequested) + { + return; + } + + if (isBuying) + { + for (int i = 0; i < Companies.Count; i++) + { + Money -= numberOfShares[i] * Companies[i].SharePrice; + Companies[i].NumberOfShares += numberOfShares[i]; + } + } + else + { + for (int i = 0; i < Companies.Count; i++) + { + Money += numberOfShares[i] * Companies[i].SharePrice; + Companies[i].NumberOfShares -= numberOfShares[i]; + } + } + + await Console.Clear(); + await Console.WriteLine(RenderCompanyStocksTable()); + await Console.WriteLine($"You shares have been updated."); + await Console.WriteLine(); + await Console.Write("Press any key to continue..."); + Console.CursorVisible = false; + CloseRequested = CloseRequested || (await Console.ReadKey(true)).Key is ConsoleKey.Escape; + } + + async Task CompanyDetailsScreen() + { + await Console.Clear(); + foreach (Company company in Companies) + { + await Console.WriteLine($"{company.Name} - {company.Description}"); + await Console.WriteLine(); + } + await Console.Write("Press any key to exit the menu..."); + Console.CursorVisible = false; + CloseRequested = CloseRequested || (await Console.ReadKey(true)).Key is ConsoleKey.Escape; + } + + 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.Write("Press any key to continue..."); + Console.CursorVisible = false; + CloseRequested = CloseRequested || (await Console.ReadKey(true)).Key is ConsoleKey.Escape; + await InitializeGame(); + 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.Write("Press any key (except ENTER) to continue..."); + ConsoleKey key = ConsoleKey.Enter; + while (!CloseRequested && key is ConsoleKey.Enter) + { + Console.CursorVisible = false; + key = (await Console.ReadKey(true)).Key; + CloseRequested = CloseRequested || key is ConsoleKey.Escape; + } + } + + 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.Write("Press any key (except ENTER) to continue..."); + ConsoleKey key = ConsoleKey.Enter; + while (!CloseRequested && key is ConsoleKey.Enter) + { + Console.CursorVisible = false; + key = (await Console.ReadKey(true)).Key; + CloseRequested = CloseRequested || key is ConsoleKey.Escape; + } + } + + 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("Press any key to continue..."); + Console.CursorVisible = false; + CloseRequested = CloseRequested || (await Console.ReadKey(true)).Key is ConsoleKey.Escape; + } + + StringBuilder RenderCompanyStocksTable() + { + // table column widths + 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)}─╢"); + foreach (Company company in Companies) + { + 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}"); + return gameView; + } + + async Task HandleMenuWithOptions(string prompt, string[] options) + { + int index = 0; + ConsoleKey key = default; + while (!CloseRequested && key is not ConsoleKey.Enter) + { + await Console.Clear(); + await Console.WriteLine(prompt); + for (int i = 0; i < options.Length; i++) + { + string currentOption = options[i]; + if (i == index) + { + (Console.BackgroundColor, Console.ForegroundColor) = (Console.ForegroundColor, Console.BackgroundColor); + await Console.WriteLine($"[*] {currentOption}"); + Console.ResetColor(); + } + else + { + await Console.WriteLine($"[ ] {currentOption}"); + } + } + Console.CursorVisible = false; + key = (await Console.ReadKey(true)).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.Escape: CloseRequested = true; break; + } + } + return index; + } + + decimal CalculateNetWorth() + { + decimal netWorth = Money; + foreach (Company company in Companies) + { + netWorth += company.SharePrice * company.NumberOfShares; + } + return netWorth; + } + } +} diff --git a/Projects/Website/Pages/Oligopoly.razor b/Projects/Website/Pages/Oligopoly.razor new file mode 100644 index 00000000..7016d3e8 --- /dev/null +++ b/Projects/Website/Pages/Oligopoly.razor @@ -0,0 +1,52 @@ +@using System + +@page "/Oligopoly" + +Oligopoly + +

Oligopoly

+ + + Go To Readme + + +
+
+
+			@Console.State
+		
+
+
+ + + + + + +
+
+ + + + + +@code +{ + Games.Oligopoly.Oligopoly Game; + BlazorConsole Console; + + public Oligopoly() + { + Game = new(); + Console = Game.Console; + Console.WindowWidth = 100; + Console.WindowHeight = 30; + Console.TriggerRefresh = StateHasChanged; + } + + protected override void OnInitialized() => InvokeAsync(Game.Run); +} diff --git a/Projects/Website/Resources.cs b/Projects/Website/Resources.cs index 57aa5cb7..27ab3883 100644 --- a/Projects/Website/Resources.cs +++ b/Projects/Website/Resources.cs @@ -8,6 +8,8 @@ public static class Resources { public static readonly string[]? Words; public static readonly string[]? FiveLetterWords; + public static readonly string? Company_json; + public static readonly string? Event_json; static Resources() { @@ -43,5 +45,25 @@ static Resources() FiveLetterWords = words.ToArray(); } } + { + const string name = "Website.Company.json"; + Assembly assembly = Assembly.GetExecutingAssembly(); + using Stream stream = assembly.GetManifestResourceStream(name)!; + if (stream is not null) + { + using StreamReader streamReader = new(stream); + Company_json = streamReader.ReadToEnd(); + } + } + { + const string name = "Website.Event.json"; + Assembly assembly = Assembly.GetExecutingAssembly(); + using Stream stream = assembly.GetManifestResourceStream(name)!; + if (stream is not null) + { + using StreamReader streamReader = new(stream); + Event_json = streamReader.ReadToEnd(); + } + } } } diff --git a/Projects/Website/Shared/NavMenu.razor b/Projects/Website/Shared/NavMenu.razor index 11649cc7..4613f36d 100644 --- a/Projects/Website/Shared/NavMenu.razor +++ b/Projects/Website/Shared/NavMenu.razor @@ -133,6 +133,11 @@ Flappy Bird + + + @code { Games.Oligopoly.Oligopoly Game;