Terjes Clicker start

This commit is contained in:
Geir Okkenhaug Jerstad 2024-11-26 12:48:02 +01:00
parent 558073a24d
commit 02e0b0815f
6 changed files with 121 additions and 0 deletions

View file

@ -0,0 +1,16 @@

Microsoft Visual Studio Solution File, Format Version 12.00
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Clicker", "Clicker\Clicker.csproj", "{872462F6-2D43-4833-ADDD-01F7115DD1F5}"
EndProject
Global
GlobalSection(SolutionConfigurationPlatforms) = preSolution
Debug|Any CPU = Debug|Any CPU
Release|Any CPU = Release|Any CPU
EndGlobalSection
GlobalSection(ProjectConfigurationPlatforms) = postSolution
{872462F6-2D43-4833-ADDD-01F7115DD1F5}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{872462F6-2D43-4833-ADDD-01F7115DD1F5}.Debug|Any CPU.Build.0 = Debug|Any CPU
{872462F6-2D43-4833-ADDD-01F7115DD1F5}.Release|Any CPU.ActiveCfg = Release|Any CPU
{872462F6-2D43-4833-ADDD-01F7115DD1F5}.Release|Any CPU.Build.0 = Release|Any CPU
EndGlobalSection
EndGlobal

View file

@ -0,0 +1,10 @@
<Project Sdk="Microsoft.NET.Sdk">
<PropertyGroup>
<OutputType>Exe</OutputType>
<TargetFramework>net8.0</TargetFramework>
<ImplicitUsings>enable</ImplicitUsings>
<Nullable>enable</Nullable>
</PropertyGroup>
</Project>

View file

@ -0,0 +1,13 @@
namespace Clicker;
public class Person
{
public string Name { get; set; }
public int Points { get; set; }
public Person(string name, int points)
{
Name = name;
Points = points;
}
}

View file

@ -0,0 +1,45 @@
using System.Text.Json;
namespace Clicker
{
internal class StaticClicker
{
public static void Main()
{
var json = File.ReadAllText("test.json");
var people = JsonSerializer.Deserialize<Person[]>(json, options);
var clickers = new Clicker[]
{
new Clicker('a'),
new Clicker('b'),
};
while (true)
{
Console.Clear();
Console.WriteLine($"Klikker A: Du har {Points} poeng. a + poeng A upgrade");
var cmdKey = Console.ReadKey(true);
HandleCommand(cmdKey);
}
}
public static void HandleCommand(cmdKey)
{
if (cmdKey.KeyChar == 'a')
{
_points += _upgrades;
}
else if (cmdKey.KeyChar == 'A')
{
if (_points >= 10)
{
_upgrades++;
_points -= 10;
}
}
}
}
}

View file

@ -0,0 +1,27 @@
namespace Clicker;
internal class Clicker
{
public int Points;
public int Upgrades;
public char Character;
public Clicker(char character)
{
Upgrades = 1;
Points = 0;
Character = character;
}
public void Show()
{
Console.Clear();
Console.WriteLine($"Clicker Simple. Du har {Points} points.");
}
public void HandleCommand(ConsoleKey cmdKey)
{
}
}

View file

@ -0,0 +1,10 @@
[
{
Name: "John",
Points: 112
},
{
Name: "Per",
Points: 45
}
]