Skip to content

Commit 73ce7e0

Browse files
Merge pull request #17 from CodebreakerApp/main
update maui from main
2 parents 6756246 + e97deac commit 73ce7e0

7 files changed

Lines changed: 60 additions & 16 deletions

File tree

.github/workflows/codebreaker-lib-viewmodels.yml

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
name: Analyzers lib
1+
name: Viewmodels lib
22

33
on:
44

@@ -7,8 +7,8 @@ on:
77
branches:
88
[ main ]
99
paths:
10-
- 'src/clients/xaml/Codebreaker.GameAPIs.ViewModels/**'
11-
- 'src/clients/xaml/Codebreaker.GameAPIs.ViewModels.Tests/**'
10+
- 'src/clients/xaml/Codebreaker.ViewModels/**'
11+
- 'src/clients/xaml/Codebreaker.ViewModels.Tests/**'
1212
- 'src/Codebreaker.ViewModels.sln'
1313
- '.github/workflows/codebreaker-lib-viewmodels.yml'
1414
- '.github/workflows/createnuget-withbuildnumber.yml'

LICENSE

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
MIT License
2+
3+
Copyright (c) 2023 CN innovation
4+
5+
Permission is hereby granted, free of charge, to any person obtaining a copy
6+
of this software and associated documentation files (the "Software"), to deal
7+
in the Software without restriction, including without limitation the rights
8+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9+
copies of the Software, and to permit persons to whom the Software is
10+
furnished to do so, subject to the following conditions:
11+
12+
The above copyright notice and this permission notice shall be included in all
13+
copies or substantial portions of the Software.
14+
15+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21+
SOFTWARE.

src/clients/xaml/CodeBreaker.ViewModels/CodeBreaker.ViewModels.csproj

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@
2323
<ItemGroup>
2424
<PackageReference Include="CommunityToolkit.Mvvm" Version="8.2.1" />
2525
<PackageReference Include="Microsoft.Extensions.Options" Version="7.0.1" />
26-
<PackageReference Include="CNinnovation.Codebreaker.GamesClient" Version="3.5.0-beta.12" />
26+
<PackageReference Include="CNinnovation.Codebreaker.GamesClient" Version="3.5.0-beta.13" />
2727
</ItemGroup>
2828

2929
<ItemGroup>

src/clients/xaml/CodeBreaker.ViewModels/Components/GameViewModel.cs

Lines changed: 2 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
using System.Collections.ObjectModel;
22

3-
using Codebreaker.GameAPIs.Client.Models;
3+
using CodeBreaker.ViewModels.Models;
44

55
namespace CodeBreaker.ViewModels.Components;
66

@@ -11,9 +11,6 @@ public class GameViewModel
1111
public GameViewModel(Game game)
1212
{
1313
_game = game;
14-
15-
ColorList = new List<string>(_game.FieldValues["colors"]);
16-
Code = new List<string>(_game.Codes);
1714
}
1815

1916
public Guid GameId => _game.GameId;
@@ -22,9 +19,7 @@ public GameViewModel(Game game)
2219

2320
public string GameType => _game.GameType;
2421

25-
public IReadOnlyList<string> Code { get; private set; }
26-
27-
public IReadOnlyList<string> ColorList { get; private set; }
22+
public IDictionary<string, string[]> FieldValues => _game.FieldValues;
2823

2924
public int NumberCodes => _game.NumberCodes;
3025

src/clients/xaml/CodeBreaker.ViewModels/Components/MoveViewModel.cs

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,4 @@
1-
using Codebreaker.GameAPIs.Client.Models;
2-
1+
using CodeBreaker.ViewModels.Models;
32

43
namespace CodeBreaker.ViewModels.Components;
54

@@ -12,7 +11,9 @@ public MoveViewModel(Move move) =>
1211

1312
public int MoveNumber => _move.MoveNumber;
1413

14+
// TODO: read-only or updates?
1515
public IReadOnlyList<string> GuessPegs => _move.GuessPegs;
1616

17-
public string[] KeyPegs => _move.KeyPegs;
17+
// TODO: read-only or updates?
18+
public string[] KeyPegs => _move.KeyPegs.ToArray();
1819
}

src/clients/xaml/CodeBreaker.ViewModels/Models/Game.cs

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,5 @@
11
using System.Collections.ObjectModel;
22

3-
using Codebreaker.GameAPIs.Client.Models;
4-
53
using CommunityToolkit.Mvvm.ComponentModel;
64

75
namespace CodeBreaker.ViewModels.Models;
Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,29 @@
1+
using System.Collections.ObjectModel;
2+
3+
using CommunityToolkit.Mvvm.ComponentModel;
4+
5+
namespace CodeBreaker.ViewModels.Models;
6+
public partial class Move(Guid moveId, int moveNumber) : ObservableObject
7+
{
8+
public Guid MoveId { get; private set; } = moveId;
9+
10+
/// <summary>
11+
/// The move number for this move within the associated game.
12+
/// </summary>
13+
[ObservableProperty]
14+
private int _moveNumber = moveNumber;
15+
16+
/// <summary>
17+
/// The guess pegs from the user for this move.
18+
/// </summary>
19+
public ObservableCollection<string> GuessPegs { get; } = new();
20+
21+
/// <summary>
22+
/// The result from the analyer for this move based on the associated game that contains the move.
23+
/// </summary>
24+
public ObservableCollection<string> KeyPegs { get; } = new();
25+
26+
public override string ToString() => $"{MoveNumber}. " +
27+
$"{string.Join('#', GuessPegs)} : " +
28+
$"{string.Join('#', KeyPegs)}";
29+
}

0 commit comments

Comments
 (0)