Skip to content

Commit 89b64c7

Browse files
committed
add card game project template
1 parent fc3a3d9 commit 89b64c7

16 files changed

+6185
-0
lines changed

CardGameProjectTemplate/App.config

+6
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
<?xml version="1.0" encoding="utf-8" ?>
2+
<configuration>
3+
<startup>
4+
<supportedRuntime version="v4.0" sku=".NETFramework,Version=v4.6.2" />
5+
</startup>
6+
</configuration>
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,98 @@
1+
<?xml version="1.0" encoding="utf-8"?>
2+
<Project ToolsVersion="15.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
3+
<Import Project="$(MSBuildExtensionsPath)\$(MSBuildToolsVersion)\Microsoft.Common.props" Condition="Exists('$(MSBuildExtensionsPath)\$(MSBuildToolsVersion)\Microsoft.Common.props')" />
4+
<PropertyGroup>
5+
<Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration>
6+
<Platform Condition=" '$(Platform)' == '' ">AnyCPU</Platform>
7+
<ProjectGuid>{8F79B246-D5A4-4C5A-A5D2-6F4F1B79F162}</ProjectGuid>
8+
<OutputType>WinExe</OutputType>
9+
<RootNamespace>CardGameProjectTemplate</RootNamespace>
10+
<AssemblyName>CardGameProjectTemplate</AssemblyName>
11+
<TargetFrameworkVersion>v4.6.2</TargetFrameworkVersion>
12+
<FileAlignment>512</FileAlignment>
13+
<AutoGenerateBindingRedirects>true</AutoGenerateBindingRedirects>
14+
<Deterministic>true</Deterministic>
15+
</PropertyGroup>
16+
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' ">
17+
<PlatformTarget>AnyCPU</PlatformTarget>
18+
<DebugSymbols>true</DebugSymbols>
19+
<DebugType>full</DebugType>
20+
<Optimize>false</Optimize>
21+
<OutputPath>bin\Debug\</OutputPath>
22+
<DefineConstants>DEBUG;TRACE</DefineConstants>
23+
<ErrorReport>prompt</ErrorReport>
24+
<WarningLevel>4</WarningLevel>
25+
</PropertyGroup>
26+
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|AnyCPU' ">
27+
<PlatformTarget>AnyCPU</PlatformTarget>
28+
<DebugType>pdbonly</DebugType>
29+
<Optimize>true</Optimize>
30+
<OutputPath>bin\Release\</OutputPath>
31+
<DefineConstants>TRACE</DefineConstants>
32+
<ErrorReport>prompt</ErrorReport>
33+
<WarningLevel>4</WarningLevel>
34+
</PropertyGroup>
35+
<ItemGroup>
36+
<Reference Include="Carubbi.Cards, Version=1.1.0.0, Culture=neutral, processorArchitecture=MSIL">
37+
<HintPath>..\packages\Carubbi.Cards.1.1.0\lib\net461\Carubbi.Cards.dll</HintPath>
38+
</Reference>
39+
<Reference Include="Carubbi.Cards.WinForms, Version=1.0.0.0, Culture=neutral, processorArchitecture=MSIL">
40+
<HintPath>..\packages\Carubbi.Cards.WinForms.1.0.0\lib\net462\Carubbi.Cards.WinForms.dll</HintPath>
41+
</Reference>
42+
<Reference Include="System" />
43+
<Reference Include="System.Core" />
44+
<Reference Include="System.Xml.Linq" />
45+
<Reference Include="System.Data.DataSetExtensions" />
46+
<Reference Include="Microsoft.CSharp" />
47+
<Reference Include="System.Data" />
48+
<Reference Include="System.Deployment" />
49+
<Reference Include="System.Drawing" />
50+
<Reference Include="System.Net.Http" />
51+
<Reference Include="System.Windows.Forms" />
52+
<Reference Include="System.Xml" />
53+
</ItemGroup>
54+
<ItemGroup>
55+
<Compile Include="Logic\Game.cs" />
56+
<Compile Include="MainForm.cs">
57+
<SubType>Form</SubType>
58+
</Compile>
59+
<Compile Include="MainForm.Designer.cs">
60+
<DependentUpon>MainForm.cs</DependentUpon>
61+
</Compile>
62+
<Compile Include="Program.cs" />
63+
<Compile Include="Properties\AssemblyInfo.cs" />
64+
<EmbeddedResource Include="MainForm.resx">
65+
<DependentUpon>MainForm.cs</DependentUpon>
66+
</EmbeddedResource>
67+
<EmbeddedResource Include="Properties\Resources.resx">
68+
<Generator>ResXFileCodeGenerator</Generator>
69+
<LastGenOutput>Resources.Designer.cs</LastGenOutput>
70+
<SubType>Designer</SubType>
71+
</EmbeddedResource>
72+
<Compile Include="Properties\Resources.Designer.cs">
73+
<AutoGen>True</AutoGen>
74+
<DependentUpon>Resources.resx</DependentUpon>
75+
<DesignTime>True</DesignTime>
76+
</Compile>
77+
<None Include="packages.config" />
78+
<None Include="Properties\Settings.settings">
79+
<Generator>SettingsSingleFileGenerator</Generator>
80+
<LastGenOutput>Settings.Designer.cs</LastGenOutput>
81+
</None>
82+
<Compile Include="Properties\Settings.Designer.cs">
83+
<AutoGen>True</AutoGen>
84+
<DependentUpon>Settings.settings</DependentUpon>
85+
<DesignTimeSharedInput>True</DesignTimeSharedInput>
86+
</Compile>
87+
</ItemGroup>
88+
<ItemGroup>
89+
<None Include="App.config" />
90+
</ItemGroup>
91+
<ItemGroup>
92+
<None Include="Resources\bg.jpg" />
93+
</ItemGroup>
94+
<ItemGroup>
95+
<None Include="Resources\cards-icon.jpg" />
96+
</ItemGroup>
97+
<Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" />
98+
</Project>

CardGameProjectTemplate/Logic/Game.cs

+87
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,87 @@
1+
using Carubbi.Cards;
2+
using System.ComponentModel;
3+
using System.Linq;
4+
using System.Runtime.CompilerServices;
5+
6+
namespace CardGameProjectTemplate.Logic
7+
{
8+
public class Game : INotifyPropertyChanged
9+
{
10+
public Game()
11+
{
12+
Deck = new Deck();
13+
14+
}
15+
16+
private string _gameNumber;
17+
18+
public string GameNumber
19+
{
20+
get => _gameNumber;
21+
set
22+
{
23+
_gameNumber = value;
24+
OnPropertyChanged();
25+
}
26+
}
27+
28+
private Deck Deck { get; }
29+
private CardSet DiscardPile { get; set; }
30+
31+
public void Discard()
32+
{
33+
if (Deck.IsEmpty)
34+
{
35+
return;
36+
}
37+
38+
DiscardCard = Deck.GetTop();
39+
DeckCard = Deck.FirstOrDefault();
40+
DiscardCard.Turn();
41+
DiscardPile.Add(DiscardCard);
42+
}
43+
44+
45+
private Card _discardCard;
46+
47+
public Card DiscardCard
48+
{
49+
get => _discardCard;
50+
set
51+
{
52+
_discardCard = value;
53+
OnPropertyChanged();
54+
}
55+
}
56+
57+
private Card _deckCard;
58+
59+
public Card DeckCard
60+
{
61+
get => _deckCard;
62+
set
63+
{
64+
_deckCard = value;
65+
OnPropertyChanged();
66+
}
67+
}
68+
69+
public event PropertyChangedEventHandler PropertyChanged;
70+
71+
72+
protected virtual void OnPropertyChanged([CallerMemberName] string propertyName = null)
73+
{
74+
PropertyChanged?.Invoke(this, new PropertyChangedEventArgs(propertyName));
75+
76+
}
77+
78+
public void Start()
79+
{
80+
Deck.Shuffle(true);
81+
DiscardPile = new CardSet();
82+
DiscardCard = null;
83+
DeckCard = Deck.First();
84+
GameNumber = $"#{Deck.GameNumber}";
85+
}
86+
}
87+
}

0 commit comments

Comments
 (0)