Skip to content

Commit

Permalink
Merge pull request #14 from kris701/expansions
Browse files Browse the repository at this point in the history
Version 0.1.3
  • Loading branch information
kris701 authored Nov 3, 2024
2 parents 215b7ba + eaa7a7f commit 91d6a69
Show file tree
Hide file tree
Showing 35 changed files with 778 additions and 129 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/dotnet-desktop.yml
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ jobs:
runs-on: windows-latest
steps:
- uses: actions/checkout@v4

- name: Compile project as publish files (WINDOWS)
run: dotnet publish .\Knuckle.Is.Bones.OpenGL\Knuckle.Is.Bones.OpenGL.csproj --configuration Release /p:PublishProfile="windows.pubxml"

Expand Down
4 changes: 1 addition & 3 deletions Knuckle.Is.Bones.Core/Engines/KnuckleBonesEngine.cs
Original file line number Diff line number Diff line change
Expand Up @@ -13,8 +13,6 @@ public class KnuckleBonesEngine
public GameState State { get; }
public bool GameOver { get; set; }

private readonly Random _rnd = new Random();

public KnuckleBonesEngine(GameSaveDefinition save)
{
Save = save;
Expand Down Expand Up @@ -106,7 +104,7 @@ public bool TakeTurn()
return true;
}

State.CurrentDice.Value = _rnd.Next(1, State.CurrentDice.Sides + 1);
State.CurrentDice.RollValue();

if (State.Turn == State.FirstOpponent.Module.OpponentID)
State.Turn = State.SecondOpponent.Module.OpponentID;
Expand Down
12 changes: 11 additions & 1 deletion Knuckle.Is.Bones.Core/Knuckle.Is.Bones.Core.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
<Authors>Kristian Skov Johansen</Authors>
<Copyright>Kristian Skov Johansen</Copyright>
<Product>Knuckle.Is.Bones Core</Product>
<Version>0.1.1</Version>
<Version>0.1.3</Version>
<SelfContained>true</SelfContained>
<DebugType>embedded</DebugType>
<PublishReadyToRun>false</PublishReadyToRun>
Expand All @@ -17,17 +17,27 @@
</PropertyGroup>

<ItemGroup>
<None Remove="Resources\Core\Boards\large.json" />
<None Remove="Resources\Core\Boards\normal.json" />
<None Remove="Resources\Core\Boards\small.json" />
<None Remove="Resources\Core\Boards\tall.json" />
<None Remove="Resources\Core\Boards\wave.json" />
<None Remove="Resources\Core\Dice\insanity.json" />
<None Remove="Resources\Core\Dice\large.json" />
<None Remove="Resources\Core\Dice\normal.json" />
<None Remove="Resources\Core\Dice\small.json" />
<None Remove="Resources\Core\Opponents\defensive.json" />
<None Remove="Resources\Core\Opponents\player.json" />
</ItemGroup>

<ItemGroup>
<EmbeddedResource Include="Resources\Core\Boards\wave.json" />
<EmbeddedResource Include="Resources\Core\Boards\large.json" />
<EmbeddedResource Include="Resources\Core\Boards\tall.json" />
<EmbeddedResource Include="Resources\Core\Boards\small.json" />
<EmbeddedResource Include="Resources\Core\Boards\normal.json" />
<EmbeddedResource Include="Resources\Core\Dice\insanity.json" />
<EmbeddedResource Include="Resources\Core\Dice\large.json" />
<EmbeddedResource Include="Resources\Core\Dice\small.json" />
<EmbeddedResource Include="Resources\Core\Dice\normal.json" />
<EmbeddedResource Include="Resources\Core\Opponents\defensive.json" />
Expand Down
7 changes: 5 additions & 2 deletions Knuckle.Is.Bones.Core/Models/Game/BoardDefinition.cs
Original file line number Diff line number Diff line change
Expand Up @@ -2,20 +2,22 @@

namespace Knuckle.Is.Bones.Core.Models.Game
{
public class BoardDefinition : IDefinition, IGenericClonable<BoardDefinition>
public class BoardDefinition : IUnlockable, IGenericClonable<BoardDefinition>
{
public Guid ID { get; set; }
public string Name { get; set; }
public string Description { get; set; }
public List<ColumnDefinition> Columns { get; set; }
public int RequiredPoints { get; set; }

[JsonConstructor]
public BoardDefinition(Guid iD, string name, string description, List<ColumnDefinition> columns)
public BoardDefinition(Guid iD, string name, string description, List<ColumnDefinition> columns, int requiredPoints)
{
ID = iD;
Name = name;
Description = description;
Columns = columns;
RequiredPoints = requiredPoints;
}

public BoardDefinition(BoardDefinition other)
Expand All @@ -26,6 +28,7 @@ public BoardDefinition(BoardDefinition other)
Columns = new List<ColumnDefinition>(other.Columns.Count);
foreach (var col in other.Columns)
Columns.Add(new ColumnDefinition(col));
RequiredPoints = other.RequiredPoints;
}

public int GetValue()
Expand Down
14 changes: 12 additions & 2 deletions Knuckle.Is.Bones.Core/Models/Game/DiceDefinition.cs
Original file line number Diff line number Diff line change
Expand Up @@ -2,22 +2,26 @@

namespace Knuckle.Is.Bones.Core.Models.Game
{
public class DiceDefinition : IDefinition, IGenericClonable<DiceDefinition>
public class DiceDefinition : IUnlockable, IGenericClonable<DiceDefinition>
{
public Guid ID { get; set; }
public string Name { get; set; }
public string Description { get; set; }
public int Sides { get; set; }
public int Value { get; set; } = 0;
public int RequiredPoints { get; set; }

private readonly Random _rnd = new Random();

[JsonConstructor]
public DiceDefinition(Guid iD, string name, string description, int sides, int value)
public DiceDefinition(Guid iD, string name, string description, int sides, int value, int requiredPoints)
{
ID = iD;
Name = name;
Description = description;
Sides = sides;
Value = value;
RequiredPoints = requiredPoints;
}

public DiceDefinition(DiceDefinition other)
Expand All @@ -27,8 +31,14 @@ public DiceDefinition(DiceDefinition other)
Description = other.Description;
Sides = other.Sides;
Value = other.Value;
RequiredPoints = other.RequiredPoints;
}

public DiceDefinition Clone() => new DiceDefinition(this);

public void RollValue()
{
Value = _rnd.Next(1, Sides + 1);
}
}
}
10 changes: 8 additions & 2 deletions Knuckle.Is.Bones.Core/Models/Game/OpponentDefinition.cs
Original file line number Diff line number Diff line change
Expand Up @@ -3,20 +3,24 @@

namespace Knuckle.Is.Bones.Core.Models.Game
{
public class OpponentDefinition : IDefinition, IGenericClonable<OpponentDefinition>
public class OpponentDefinition : IUnlockable, IGenericClonable<OpponentDefinition>
{
public Guid ID { get; set; }
public string Name { get; set; }
public string Description { get; set; }
public IOpponentModule Module { get; set; }
public double Difficulty { get; set; }
public int RequiredPoints { get; set; }

[JsonConstructor]
public OpponentDefinition(Guid iD, string name, string description, IOpponentModule module)
public OpponentDefinition(Guid iD, string name, string description, IOpponentModule module, double difficulty, int requiredPoints)
{
ID = iD;
Name = name;
Description = description;
Module = module;
Difficulty = difficulty;
RequiredPoints = requiredPoints;
}

public OpponentDefinition(OpponentDefinition other)
Expand All @@ -28,6 +32,8 @@ public OpponentDefinition(OpponentDefinition other)
Module = module;
else
throw new ArgumentException("Could not clone module!");
Difficulty = other.Difficulty;
RequiredPoints = other.RequiredPoints;
}

public OpponentDefinition Clone() => new OpponentDefinition(this);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ public void SetTargetColumn(DiceDefinition diceValue, BoardDefinition myBoard, B
var index = 0;
foreach(var column in opponentBoard.Columns)
{
if (column.Cells.Any(x => x == diceValue.Value))
if (column.Cells.Any(x => x == diceValue.Value) && !myBoard.Columns[index].IsFull())
{
_targetColumn = index;
return;
Expand Down
7 changes: 7 additions & 0 deletions Knuckle.Is.Bones.Core/Models/IUnlockable.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
namespace Knuckle.Is.Bones.Core.Models
{
public interface IUnlockable : IDefinition
{
public int RequiredPoints { get; set; }
}
}
9 changes: 8 additions & 1 deletion Knuckle.Is.Bones.Core/Models/Saves/UserSaveDefinition.cs
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,16 @@

namespace Knuckle.Is.Bones.Core.Models.Saves
{
public class UserSaveDefinition
public class UserSaveDefinition<T>
{
public int AllTimeScore { get; set; }
public T UIData { get; set; }

public UserSaveDefinition(int allTimeScore, T uIData)
{
AllTimeScore = allTimeScore;
UIData = uIData;
}

public void Save()
{
Expand Down
20 changes: 20 additions & 0 deletions Knuckle.Is.Bones.Core/Resources/Core/Boards/large.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
{
"ID": "09144a57-a719-47bd-a36c-1cfb287c295d",
"Name": "Large",
"Description": "A large 4x4 field.",
"RequiredPoints": 2000,
"Columns": [
{
"Cells": [ 0, 0, 0, 0 ]
},
{
"Cells": [ 0, 0, 0, 0 ]
},
{
"Cells": [ 0, 0, 0, 0 ]
},
{
"Cells": [ 0, 0, 0, 0 ]
}
]
}
1 change: 1 addition & 0 deletions Knuckle.Is.Bones.Core/Resources/Core/Boards/normal.json
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
"ID": "907bddf8-cbe1-49f4-a1f8-92ad5266f116",
"Name": "Normal",
"Description": "A normal 3x3 field.",
"RequiredPoints": 0,
"Columns": [
{
"Cells": [ 0, 0, 0 ]
Expand Down
1 change: 1 addition & 0 deletions Knuckle.Is.Bones.Core/Resources/Core/Boards/small.json
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
"ID": "9cbc4760-d71b-482c-ab06-f05fecedd741",
"Name": "Low",
"Description": "A lower 3x2 field.",
"RequiredPoints": 0,
"Columns": [
{
"Cells": [ 0, 0 ]
Expand Down
17 changes: 17 additions & 0 deletions Knuckle.Is.Bones.Core/Resources/Core/Boards/tall.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
{
"ID": "322dbaa5-c806-4b56-af9d-164b135a6d42",
"Name": "Tall",
"Description": "A tall 3x4 field.",
"RequiredPoints": 1000,
"Columns": [
{
"Cells": [ 0, 0, 0, 0 ]
},
{
"Cells": [ 0, 0, 0, 0 ]
},
{
"Cells": [ 0, 0, 0, 0 ]
}
]
}
23 changes: 23 additions & 0 deletions Knuckle.Is.Bones.Core/Resources/Core/Boards/wave.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
{
"ID": "0ac3da70-4cb8-4e97-9af9-4b9759499dd7",
"Name": "Wave",
"Description": "A weird wavy field",
"RequiredPoints": 3000,
"Columns": [
{
"Cells": [ 0, 0 ]
},
{
"Cells": [ 0, 0, 0 ]
},
{
"Cells": [ 0, 0, 0, 0 ]
},
{
"Cells": [ 0, 0, 0 ]
},
{
"Cells": [ 0, 0 ]
}
]
}
8 changes: 8 additions & 0 deletions Knuckle.Is.Bones.Core/Resources/Core/Dice/insanity.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
{
"ID": "a80ca420-879b-47b7-adbf-7ada87b5939c",
"Name": "Insanity",
"Description": "A ridiculous 50 sided dice!",
"Sides": 50,
"Value": 0,
"RequiredPoints": 2000
}
8 changes: 8 additions & 0 deletions Knuckle.Is.Bones.Core/Resources/Core/Dice/large.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
{
"ID": "9c935082-05b7-4b7e-9064-d6beb077ea8c",
"Name": "Large",
"Description": "A bigger 10 sided dice",
"Sides": 10,
"Value": 0,
"RequiredPoints": 1000
}
3 changes: 2 additions & 1 deletion Knuckle.Is.Bones.Core/Resources/Core/Dice/normal.json
Original file line number Diff line number Diff line change
Expand Up @@ -3,5 +3,6 @@
"Name": "Normal",
"Description": "A normal 6 sided dice",
"Sides": 6,
"Value": 0
"Value": 0,
"RequiredPoints": 0
}
3 changes: 2 additions & 1 deletion Knuckle.Is.Bones.Core/Resources/Core/Dice/small.json
Original file line number Diff line number Diff line change
Expand Up @@ -3,5 +3,6 @@
"Name": "Small",
"Description": "A small 3 sided dice",
"Sides": 3,
"Value": 0
"Value": 0,
"RequiredPoints": 0
}
2 changes: 2 additions & 0 deletions Knuckle.Is.Bones.Core/Resources/Core/Opponents/defensive.json
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,8 @@
"ID": "9dd2041e-f8bc-4c44-8fcd-5424f9748ca6",
"Name": "Defensive",
"Description": "An AI that will always try to remove dice from the opponents board.",
"Difficulty": 2,
"RequiredPoints": 0,
"Module": {
"OpponentModule": "Defensive"
}
Expand Down
2 changes: 2 additions & 0 deletions Knuckle.Is.Bones.Core/Resources/Core/Opponents/player.json
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,8 @@
"ID": "d6032478-b6ec-483e-8750-5976830d66b2",
"Name": "Player",
"Description": "A human player.",
"Difficulty": 1,
"RequiredPoints": 0,
"Module": {
"OpponentModule": "Player"
}
Expand Down
2 changes: 2 additions & 0 deletions Knuckle.Is.Bones.Core/Resources/Core/Opponents/random.json
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,8 @@
"ID": "42244cf9-6ad3-4729-8376-a0d323440a18",
"Name": "Random",
"Description": "An AI that randomly places dice.",
"Difficulty": 1.5,
"RequiredPoints": 0,
"Module": {
"OpponentModule": "Random"
}
Expand Down
4 changes: 2 additions & 2 deletions Knuckle.Is.Bones.OpenGL/Knuckle.Is.Bones.OpenGL.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
<Authors>Kristian Skov Johansen</Authors>
<Copyright>Kristian Skov Johansen</Copyright>
<Product>Knuckle.Is.Bones</Product>
<Version>0.1.2</Version>
<Version>0.1.3</Version>
<PublishSingleFile>true</PublishSingleFile>
<SelfContained>true</SelfContained>
<DebugType>embedded</DebugType>
Expand Down Expand Up @@ -38,7 +38,7 @@
<ItemGroup>
<PackageReference Include="MonoGame.Framework.DesktopGL" Version="3.8.2.1105" />
<PackageReference Include="MonoGame.Content.Builder.Task" Version="3.8.2.1105" />
<PackageReference Include="MonoGame.OpenGL.Formatter" Version="1.0.21" />
<PackageReference Include="MonoGame.OpenGL.Formatter" Version="1.0.22" />
</ItemGroup>
<ItemGroup>
<ProjectReference Include="..\Knuckle.Is.Bones.Core\Knuckle.Is.Bones.Core.csproj" />
Expand Down
Loading

0 comments on commit 91d6a69

Please sign in to comment.