Skip to content

Commit

Permalink
comment
Browse files Browse the repository at this point in the history
  • Loading branch information
valya1 committed May 2, 2016
1 parent 102c99f commit fa8b5f2
Show file tree
Hide file tree
Showing 8 changed files with 428 additions and 0 deletions.
28 changes: 28 additions & 0 deletions Backgammon.sln
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@

Microsoft Visual Studio Solution File, Format Version 12.00
# Visual Studio 14
VisualStudioVersion = 14.0.23107.0
MinimumVisualStudioVersion = 10.0.40219.1
Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "Backgammon", "Backgammon\Backgammon.vcxproj", "{4051CE38-20C9-4D2C-9DCC-B4DDB0C9EEE5}"
EndProject
Global
GlobalSection(SolutionConfigurationPlatforms) = preSolution
Debug|x64 = Debug|x64
Debug|x86 = Debug|x86
Release|x64 = Release|x64
Release|x86 = Release|x86
EndGlobalSection
GlobalSection(ProjectConfigurationPlatforms) = postSolution
{4051CE38-20C9-4D2C-9DCC-B4DDB0C9EEE5}.Debug|x64.ActiveCfg = Debug|x64
{4051CE38-20C9-4D2C-9DCC-B4DDB0C9EEE5}.Debug|x64.Build.0 = Debug|x64
{4051CE38-20C9-4D2C-9DCC-B4DDB0C9EEE5}.Debug|x86.ActiveCfg = Debug|Win32
{4051CE38-20C9-4D2C-9DCC-B4DDB0C9EEE5}.Debug|x86.Build.0 = Debug|Win32
{4051CE38-20C9-4D2C-9DCC-B4DDB0C9EEE5}.Release|x64.ActiveCfg = Release|x64
{4051CE38-20C9-4D2C-9DCC-B4DDB0C9EEE5}.Release|x64.Build.0 = Release|x64
{4051CE38-20C9-4D2C-9DCC-B4DDB0C9EEE5}.Release|x86.ActiveCfg = Release|Win32
{4051CE38-20C9-4D2C-9DCC-B4DDB0C9EEE5}.Release|x86.Build.0 = Release|Win32
EndGlobalSection
GlobalSection(SolutionProperties) = preSolution
HideSolutionNode = FALSE
EndGlobalSection
EndGlobal
141 changes: 141 additions & 0 deletions Backgammon/Backgammon.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,141 @@
#include "stdafx.h"
#include <iostream>
#include<ctime>
#include<string>
#include<vector>
#define vecint vector<int>
#define vecstr vector<string>

using namespace std;

vecstr chip(25);
vecint amount(25);
int player = 1, dice1, dice2;
string p[2] = { "#", "*" };

void init()
{
amount[12] = 15;
chip[12] = "*";
amount[0] = 15;
chip[0] = "#";
}

void show_field()
{
int pos = 11; // ãåíåðàöèÿ ñ 11 ÿ÷åéêè
cout << " 11 10 9 8 7 6 5 4 3 2 1 0" << endl;
cout << "---------------------------------------------------------------" << endl;
for (int i = 0; i < 15; i++) // ïåðâûå 15 ñòðîê
{
pos = 11;
cout << "| ";
for (int j = 0; j < 12; j++)
{
if (amount[pos] - i > 0)
{
cout << " " + chip[pos] + " ";
}
else cout << " ";
if (j == 5)
cout << "|";
pos--;
}
cout << "|" << endl;
}
for (int i = 15; i > 0; i--) // ïîñëåäíèå 15 ñòðîê
{
pos = 12;
cout << "| ";
for (int j = 0; j < 12; j++)
{
if (amount[pos] - i >= 0)
{
cout << " " + chip[pos] + " ";
}
else cout << " ";
if (j == 5)
cout << "|";
pos++;
}
cout << "|" << endl;
}


cout << "---------------------------------------------------------------" << endl;
cout << " 12 13 14 15 16 17 18 19 20 21 22 23" << endl;
for (int i = 0; i < 3; i++)
cout << endl;
}

void throw_dice()
{
srand(time(0));
dice1 = rand() % 6 + 1;
dice2 = rand() % 6 + 1;
cout << " Íà ïåðâîì êóáèêå âûïàëî: " << dice1 << endl;
cout << " Íà âòîðîì êóáèêå âûïàëî: " << dice2 << endl;
}

void turn(int player)
{
vecint dices;
int pos, points;
bool flag = 0; // ïðèçíàê òîãî, ÷òî õîä âåðåí
throw_dice();
dices.push_back(dice1);
dices.push_back(dice2);
if (dice1 == dice2) // äóáëü
{
cout << "Âàì âûïàë äóáëü!!!" << endl << endl;;
dices.push_back(dice1);
dices.push_back(dice2);
}
while (!dices.empty())
{
cout << "Ââåäèòå íîìåð ÿ÷åéêè, îòêóäà ïåðåñòàâëÿòü: ";
cin >> pos;
while (chip[pos] != p[player - 1])
{
cout << "Õâàòèò õîäèòü ÷óæèìè ôèøêàìè!" << endl;
cin >> pos;
}
cout << "Êîëè÷åñòâî î÷êîâ: ";
cin >> points;
for (int i = 0; i < dices.size(); i++)
if (points == dices[i])
{
dices.erase(dices.begin() + i); // óäàëÿåì êóáèê èç ìàññèâà êóáèêîâ
flag = true;
break;
}
if (flag)
{
chip[pos + points] = chip[pos];
amount[pos]--;
amount[pos + points]++;

system("cls");
show_field();

if (!dices.empty())
cout << "Ó âàñ îñòàëèñü ñëåäóþùèå õîäû: " << endl;
for (int i = 0; i < dices.size(); i++)
cout << dices[i] << " ";
cout << endl;
flag = false;
}
}
player = (player % 2) + 1;
}


int main()
{
setlocale(LC_ALL, "Rus");
init();
show_field();
turn(player);
system("pause");
return 0;
}
162 changes: 162 additions & 0 deletions Backgammon/Backgammon.vcxproj
Original file line number Diff line number Diff line change
@@ -0,0 +1,162 @@
<?xml version="1.0" encoding="utf-8"?>
<Project DefaultTargets="Build" ToolsVersion="14.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
<ItemGroup Label="ProjectConfigurations">
<ProjectConfiguration Include="Debug|Win32">
<Configuration>Debug</Configuration>
<Platform>Win32</Platform>
</ProjectConfiguration>
<ProjectConfiguration Include="Release|Win32">
<Configuration>Release</Configuration>
<Platform>Win32</Platform>
</ProjectConfiguration>
<ProjectConfiguration Include="Debug|x64">
<Configuration>Debug</Configuration>
<Platform>x64</Platform>
</ProjectConfiguration>
<ProjectConfiguration Include="Release|x64">
<Configuration>Release</Configuration>
<Platform>x64</Platform>
</ProjectConfiguration>
</ItemGroup>
<PropertyGroup Label="Globals">
<ProjectGuid>{4051CE38-20C9-4D2C-9DCC-B4DDB0C9EEE5}</ProjectGuid>
<Keyword>Win32Proj</Keyword>
<RootNamespace>Backgammon</RootNamespace>
<WindowsTargetPlatformVersion>8.1</WindowsTargetPlatformVersion>
</PropertyGroup>
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.Default.props" />
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'" Label="Configuration">
<ConfigurationType>Application</ConfigurationType>
<UseDebugLibraries>true</UseDebugLibraries>
<PlatformToolset>v140</PlatformToolset>
<CharacterSet>Unicode</CharacterSet>
</PropertyGroup>
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'" Label="Configuration">
<ConfigurationType>Application</ConfigurationType>
<UseDebugLibraries>false</UseDebugLibraries>
<PlatformToolset>v140</PlatformToolset>
<WholeProgramOptimization>true</WholeProgramOptimization>
<CharacterSet>Unicode</CharacterSet>
</PropertyGroup>
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|x64'" Label="Configuration">
<ConfigurationType>Application</ConfigurationType>
<UseDebugLibraries>true</UseDebugLibraries>
<PlatformToolset>v140</PlatformToolset>
<CharacterSet>Unicode</CharacterSet>
</PropertyGroup>
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|x64'" Label="Configuration">
<ConfigurationType>Application</ConfigurationType>
<UseDebugLibraries>false</UseDebugLibraries>
<PlatformToolset>v140</PlatformToolset>
<WholeProgramOptimization>true</WholeProgramOptimization>
<CharacterSet>Unicode</CharacterSet>
</PropertyGroup>
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.props" />
<ImportGroup Label="ExtensionSettings">
</ImportGroup>
<ImportGroup Label="Shared">
</ImportGroup>
<ImportGroup Label="PropertySheets" Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">
<Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" />
</ImportGroup>
<ImportGroup Label="PropertySheets" Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">
<Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" />
</ImportGroup>
<ImportGroup Label="PropertySheets" Condition="'$(Configuration)|$(Platform)'=='Debug|x64'">
<Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" />
</ImportGroup>
<ImportGroup Label="PropertySheets" Condition="'$(Configuration)|$(Platform)'=='Release|x64'">
<Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" />
</ImportGroup>
<PropertyGroup Label="UserMacros" />
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">
<LinkIncremental>true</LinkIncremental>
</PropertyGroup>
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|x64'">
<LinkIncremental>true</LinkIncremental>
</PropertyGroup>
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">
<LinkIncremental>false</LinkIncremental>
</PropertyGroup>
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|x64'">
<LinkIncremental>false</LinkIncremental>
</PropertyGroup>
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">
<ClCompile>
<PrecompiledHeader>
</PrecompiledHeader>
<WarningLevel>Level3</WarningLevel>
<Optimization>Disabled</Optimization>
<PreprocessorDefinitions>WIN32;_DEBUG;_CONSOLE;%(PreprocessorDefinitions)</PreprocessorDefinitions>
<SDLCheck>true</SDLCheck>
</ClCompile>
<Link>
<SubSystem>Console</SubSystem>
<GenerateDebugInformation>true</GenerateDebugInformation>
</Link>
</ItemDefinitionGroup>
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Debug|x64'">
<ClCompile>
<PrecompiledHeader>
</PrecompiledHeader>
<WarningLevel>Level3</WarningLevel>
<Optimization>Disabled</Optimization>
<PreprocessorDefinitions>_DEBUG;_CONSOLE;%(PreprocessorDefinitions)</PreprocessorDefinitions>
<SDLCheck>true</SDLCheck>
</ClCompile>
<Link>
<SubSystem>Console</SubSystem>
<GenerateDebugInformation>true</GenerateDebugInformation>
</Link>
</ItemDefinitionGroup>
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">
<ClCompile>
<WarningLevel>Level3</WarningLevel>
<PrecompiledHeader>
</PrecompiledHeader>
<Optimization>MaxSpeed</Optimization>
<FunctionLevelLinking>true</FunctionLevelLinking>
<IntrinsicFunctions>true</IntrinsicFunctions>
<PreprocessorDefinitions>WIN32;NDEBUG;_CONSOLE;%(PreprocessorDefinitions)</PreprocessorDefinitions>
<SDLCheck>true</SDLCheck>
</ClCompile>
<Link>
<SubSystem>Console</SubSystem>
<GenerateDebugInformation>true</GenerateDebugInformation>
<EnableCOMDATFolding>true</EnableCOMDATFolding>
<OptimizeReferences>true</OptimizeReferences>
</Link>
</ItemDefinitionGroup>
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Release|x64'">
<ClCompile>
<WarningLevel>Level3</WarningLevel>
<PrecompiledHeader>
</PrecompiledHeader>
<Optimization>MaxSpeed</Optimization>
<FunctionLevelLinking>true</FunctionLevelLinking>
<IntrinsicFunctions>true</IntrinsicFunctions>
<PreprocessorDefinitions>NDEBUG;_CONSOLE;%(PreprocessorDefinitions)</PreprocessorDefinitions>
<SDLCheck>true</SDLCheck>
</ClCompile>
<Link>
<SubSystem>Console</SubSystem>
<GenerateDebugInformation>true</GenerateDebugInformation>
<EnableCOMDATFolding>true</EnableCOMDATFolding>
<OptimizeReferences>true</OptimizeReferences>
</Link>
</ItemDefinitionGroup>
<ItemGroup>
<Text Include="ReadMe.txt" />
</ItemGroup>
<ItemGroup>
<ClInclude Include="stdafx.h" />
<ClInclude Include="targetver.h" />
</ItemGroup>
<ItemGroup>
<ClCompile Include="Backgammon.cpp" />
<ClCompile Include="stdafx.cpp" />
</ItemGroup>
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.targets" />
<ImportGroup Label="ExtensionTargets">
</ImportGroup>
</Project>
36 changes: 36 additions & 0 deletions Backgammon/Backgammon.vcxproj.filters
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
<?xml version="1.0" encoding="utf-8"?>
<Project ToolsVersion="4.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
<ItemGroup>
<Filter Include="Файлы исходного кода">
<UniqueIdentifier>{4FC737F1-C7A5-4376-A066-2A32D752A2FF}</UniqueIdentifier>
<Extensions>cpp;c;cc;cxx;def;odl;idl;hpj;bat;asm;asmx</Extensions>
</Filter>
<Filter Include="Заголовочные файлы">
<UniqueIdentifier>{93995380-89BD-4b04-88EB-625FBE52EBFB}</UniqueIdentifier>
<Extensions>h;hh;hpp;hxx;hm;inl;inc;xsd</Extensions>
</Filter>
<Filter Include="Файлы ресурсов">
<UniqueIdentifier>{67DA6AB6-F800-4c08-8B7A-83BB121AAD01}</UniqueIdentifier>
<Extensions>rc;ico;cur;bmp;dlg;rc2;rct;bin;rgs;gif;jpg;jpeg;jpe;resx;tiff;tif;png;wav;mfcribbon-ms</Extensions>
</Filter>
</ItemGroup>
<ItemGroup>
<Text Include="ReadMe.txt" />
</ItemGroup>
<ItemGroup>
<ClInclude Include="stdafx.h">
<Filter>Заголовочные файлы</Filter>
</ClInclude>
<ClInclude Include="targetver.h">
<Filter>Заголовочные файлы</Filter>
</ClInclude>
</ItemGroup>
<ItemGroup>
<ClCompile Include="stdafx.cpp">
<Filter>Файлы исходного кода</Filter>
</ClCompile>
<ClCompile Include="Backgammon.cpp">
<Filter>Файлы исходного кода</Filter>
</ClCompile>
</ItemGroup>
</Project>
Loading

0 comments on commit fa8b5f2

Please sign in to comment.