Skip to content

Commit

Permalink
v7.0
Browse files Browse the repository at this point in the history
  • Loading branch information
richelbilderbeek committed Nov 14, 2015
1 parent 4d3caa1 commit 625d2d8
Show file tree
Hide file tree
Showing 38 changed files with 590 additions and 233 deletions.
6 changes: 6 additions & 0 deletions K3OpEenRij.qrc
Original file line number Diff line number Diff line change
Expand Up @@ -23,5 +23,11 @@
<file>K3OpEenRijIcon.png</file>
<file>K3OpEenRijKiesJosje.png</file>
<file>K3OpEenRijKiesKathleen.png</file>
<file>K3OpEenRijHanne.png</file>
<file>K3OpEenRijHanneGrey.png</file>
<file>K3OpEenRijKlaasjeGrey.png</file>
<file>K3OpEenRijKlaasje.png</file>
<file>K3OpEenRijMarthe.png</file>
<file>K3OpEenRijMartheGrey.png</file>
</qresource>
</RCC>
6 changes: 4 additions & 2 deletions K3OpEenRijConsole.pri
Original file line number Diff line number Diff line change
Expand Up @@ -3,11 +3,13 @@ INCLUDEPATH += \

SOURCES += \
../K3OpEenRij/k3opeenrijmenudialog.cpp \
../K3OpEenRij/qtk3opeenrijresources.cpp
../K3OpEenRij/qtk3opeenrijresources.cpp \
../K3OpEenRij/k3opeenrijnames.cpp

HEADERS += \
../K3OpEenRij/k3opeenrijmenudialog.h \
../K3OpEenRij/qtk3opeenrijresources.h
../K3OpEenRij/qtk3opeenrijresources.h \
../K3OpEenRij/k3opeenrijnames.h

RESOURCES += \
../K3OpEenRij/K3OpEenRij.qrc
Expand Down
2 changes: 1 addition & 1 deletion K3OpEenRijConsole.pro
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ include(../RibiClasses/CppConnectThree/CppConnectThree.pri)
include(../RibiClasses/CppConnectThreeWidget/CppConnectThreeWidget.pri)
include(../RibiClasses/CppDotMatrix/CppDotMatrix.pri)
include(../RibiClasses/CppTribool/CppTribool.pri)
include(../ConnectThree/GameConnectThreeConsole.pri)
include(../ConnectThree/ConnectThreeConsole.pri)

include(K3OpEenRijConsole.pri)

Expand Down
2 changes: 1 addition & 1 deletion K3OpEenRijDesktop.pro
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ include(../RibiClasses/CppTribool/CppTribool.pri)

#Specific, desktop
include(../RibiClasses/CppQtConnectThreeWidget/CppQtConnectThreeWidget.pri)
include(../ConnectThree/GameConnectThreeDesktop.pri)
include(../ConnectThree/ConnectThreeDesktop.pri)

include(K3OpEenRijDesktop.pri)

Expand Down
Binary file modified K3OpEenRijHanne.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified K3OpEenRijHanneGrey.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified K3OpEenRijKlaasje.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified K3OpEenRijKlaasjeGrey.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified K3OpEenRijMarthe.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified K3OpEenRijMartheGrey.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
27 changes: 25 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,2 +1,25 @@
# K3OpEenRij
C++ game of connect-three with K3 theme
# K3-Op-Een-Rij

C++ game of connect-three with K3 theme.

# Screenshot

Most recent at the top.

![K3-Op-Een-Rij menu of version 7.0](Screenshots/K3OpEenRijMenu_7_0.png)
![K3-Op-Een-Rij instructions of version 7.0](Screenshots/K3OpEenRijInstructions_7_0.png)
![K3-Op-Een-Rij game version 7.0](Screenshots/K3OpEenRij_7_0.png)

![K3-Op-Een-Rij game version 6.0](Screenshots/K3OpEenRij_6_0.png)

![K3-Op-Een-Rij game version 5.1 on Lubuntu](Screenshots/K3OpEenRij_5_1Lubuntu.png)
![K3-Op-Een-Rij game version 5.1 on Windows](Screenshots/K3OpEenRij_5_1Windows.png)

![K3-Op-Een-Rij game version 5.0](Screenshots/K3OpEenRij_5_0.png)

![K3-Op-Een-Rij menu of version 5.0](Screenshots/K3OpEenRijMenu_5_0.png)

![K3-Op-Een-Rij menu of version 4.0](Screenshots/K3OpEenRijMenu_4_0.png)
![K3-Op-Een-Rij game version 4.0](Screenshots/K3OpEenRij_4_0.png)

![K3-Op-Een-Rij game version 3.0](Screenshots/K3OpEenRij_3_0.png)
Binary file added Screenshots/K3OpEenRijInstructions_7_0.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added Screenshots/K3OpEenRijMenu_4_0.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added Screenshots/K3OpEenRijMenu_5_0.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added Screenshots/K3OpEenRijMenu_7_0.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added Screenshots/K3OpEenRij_3_0.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added Screenshots/K3OpEenRij_4_0.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added Screenshots/K3OpEenRij_5_0.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added Screenshots/K3OpEenRij_5_1Lubuntu.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added Screenshots/K3OpEenRij_5_1Windows.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added Screenshots/K3OpEenRij_6_0.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added Screenshots/K3OpEenRij_7_0.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
83 changes: 18 additions & 65 deletions k3opeenrijmenudialog.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -10,15 +10,15 @@
#include <stdexcept>


#include "connectthree.h"
#include "connectthreegame.h"
#include "connectthreewidget.h"
#include "qtk3opeenrijresources.h"
#include "richelbilderbeekprogram.h"
#include "testtimer.h"
#include "trace.h"
#pragma GCC diagnostic pop

int ribi::K3OpEenRijMenuDialog::ExecuteSpecific(const std::vector<std::string>& argv) noexcept
int ribi::koer::MenuDialog::ExecuteSpecific(const std::vector<std::string>& argv) noexcept
{
using namespace ::ribi::con3;
#ifndef NDEBUG
Expand All @@ -31,15 +31,13 @@ int ribi::K3OpEenRijMenuDialog::ExecuteSpecific(const std::vector<std::string>&
{

//Play a ConnectThreeGame, but change the graphics
boost::shared_ptr<ConnectThree> c {
new ConnectThree(15,5)
};
Game c(15,5);
const std::bitset<3> is_player_human(0);
while (c->GetWinner() == Winner::no_winner)
while (c.GetWinner() == Winner::no_winner)
{
c->DoMove(c->SuggestMove(is_player_human));
c.DoMove(c.SuggestMove(is_player_human));
std::stringstream s;
s << (*c);
s << c;
std::string t { s.str() };
//Replace
std::replace(t.begin(),t.end(),'1','K'); //Karen
Expand All @@ -49,7 +47,7 @@ int ribi::K3OpEenRijMenuDialog::ExecuteSpecific(const std::vector<std::string>&
<< std::endl;
}

switch (c->GetWinner())
switch (c.GetWinner())
{
case Winner::player1 : std::cout << "Karen won the game"; break;
case Winner::player2 : std::cout << "Kristel won the game"; break;
Expand All @@ -63,34 +61,14 @@ int ribi::K3OpEenRijMenuDialog::ExecuteSpecific(const std::vector<std::string>&
std::cout << std::endl;
return 0;
}
else if (argc == 2 && (argv[1] == "-1" || argv[1] == "--Karen"))
{
Show(0);
return 0;
}
else if (argc == 2 && (argv[1] == "-2" || argv[1] == "--Kristel"))
{
Show(1);
return 0;
}
else if (argc == 2 && (argv[1] == "-3" || argv[1] == "--Josje"))
{
Show(2);
return 0;
}
else if (argc == 2 && (argv[1] == "-4" || argv[1] == "--Kathleen"))
{
Show(3);
return 0;
}
else
{
std::cout << GetHelp() << '\n';
return 1;
}
}

ribi::About ribi::K3OpEenRijMenuDialog::GetAbout() const noexcept
ribi::About ribi::koer::MenuDialog::GetAbout() const noexcept
{
About a(
"Richel Bilderbeek",
Expand All @@ -101,40 +79,34 @@ ribi::About ribi::K3OpEenRijMenuDialog::GetAbout() const noexcept
"http://www.richelbilderbeek.nl/GameK3OpEenRij.htm",
GetVersion(),
GetVersionHistory());
a.AddLibrary("ConnectThree version: " + con3::ConnectThree::GetVersion());
a.AddLibrary("ConnectThree version: " + con3::Game::GetVersion());
a.AddLibrary("ConnectThreeWidget version: " + con3::ConnectThreeWidget::GetVersion());
a.AddLibrary("TestTimer version: " + TestTimer::GetVersion());
a.AddLibrary("Special thanks to Mark Wiering for his excellent bug reports");
return a;
}

ribi::Help ribi::K3OpEenRijMenuDialog::GetHelp() const noexcept
ribi::Help ribi::koer::MenuDialog::GetHelp() const noexcept
{
return Help(
GetAbout().GetFileTitle(),
GetAbout().GetFileDescription(),
{
Help::Option('d',"demo","Display a demo game"),
Help::Option('1',"Karen","Display Karen"),
Help::Option('2',"Kristel","Display Kristel"),
Help::Option('3',"Josje","Display Josje"),
Help::Option('4',"Kathleen","Display Kathleen")
Help::Option('d',"demo","Display a demo game")
},
{
GetAbout().GetFileTitle() + " -d",
GetAbout().GetFileTitle() + " --demo",
GetAbout().GetFileTitle() + " -1",
GetAbout().GetFileTitle() + " --Karen"
GetAbout().GetFileTitle() + " --demo"
}
);
}

std::string ribi::K3OpEenRijMenuDialog::GetVersion() const noexcept
std::string ribi::koer::MenuDialog::GetVersion() const noexcept
{
return "7.0";
}

std::vector<std::string> ribi::K3OpEenRijMenuDialog::GetVersionHistory() const noexcept
std::vector<std::string> ribi::koer::MenuDialog::GetVersionHistory() const noexcept
{
return {
"2007-01-03: version 3.0: initial C++ Builder verion",
Expand All @@ -149,39 +121,20 @@ std::vector<std::string> ribi::K3OpEenRijMenuDialog::GetVersionHistory() const n
};
}

void ribi::K3OpEenRijMenuDialog::Show(const int girl_index) const noexcept
{
QtK3OpEenRijResources r(girl_index == 3 ? Tribool::True : Tribool::False);
assert(r.GetPlayersFilenames().size() == 3);
assert(girl_index >= 0);
assert(girl_index >= 0);
const std::string filename = r.GetPlayersFilenames()[girl_index == 3 ? 2 : girl_index];
QtK3OpEenRijResources::CreateFile(filename);
/*
const boost::shared_ptr<ImageCanvas> canvas {
new ImageCanvas(filename,78)
};
std::cout << (*canvas) << std::endl;
*/
assert(!"TODO");
}

#ifndef NDEBUG
void ribi::K3OpEenRijMenuDialog::Test() noexcept
void ribi::koer::MenuDialog::Test() noexcept
{
{
static bool is_tested{false};
if (is_tested) return;
is_tested = true;
}
const TestTimer test_timer(__func__,__FILE__,1.0);
boost::shared_ptr<con3::ConnectThree> c {
new con3::ConnectThree(15,5)
};
ribi::con3::Game c(15,5);
const std::bitset<3> is_player_human(0);
while (c->GetWinner() == con3::Winner::no_winner)
while (c.GetWinner() == con3::Winner::no_winner)
{
c->DoMove(c->SuggestMove(is_player_human));
c.DoMove(c.SuggestMove(is_player_human));
}
}
#endif
6 changes: 3 additions & 3 deletions k3opeenrijmenudialog.h
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,9 @@
#include "menudialog.h"

namespace ribi {
namespace koer {

struct K3OpEenRijMenuDialog final : public MenuDialog
struct MenuDialog final : public ::ribi::MenuDialog
{
About GetAbout() const noexcept override;
Help GetHelp() const noexcept override;
Expand All @@ -15,13 +16,12 @@ struct K3OpEenRijMenuDialog final : public MenuDialog
private:
int ExecuteSpecific(const std::vector<std::string>& argv) noexcept override;

void Show(const int girl_index) const noexcept;

#ifndef NDEBUG
static void Test() noexcept;
#endif
};

} //~namespace koer
} //~namespace ribi

#endif // K3OPEENRIJMENUDIALOG_H
70 changes: 70 additions & 0 deletions k3opeenrijnames.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,70 @@
#include "k3opeenrijnames.h"

#include <cassert>
#include <stdexcept>

ribi::koer::BlackHairedGirl ribi::koer::GetNext(
const BlackHairedGirl girl
) noexcept
{
switch (girl) {
case BlackHairedGirl::kristel: return BlackHairedGirl::marthe;
case BlackHairedGirl::marthe: return BlackHairedGirl::kristel;
}
assert(!"Should not get here");
throw std::logic_error("Unknown girl");
}

ribi::koer::BlondeGirl ribi::koer::GetNext(const BlondeGirl girl) noexcept
{
switch (girl) {
case BlondeGirl::kathleen: return BlondeGirl::josje;
case BlondeGirl::josje: return BlondeGirl::klaasje;
case BlondeGirl::klaasje: return BlondeGirl::kathleen;
}
assert(!"Should not get here");
throw std::logic_error("Unknown girl");

}

ribi::koer::RedHairedGirl ribi::koer::GetNext(const RedHairedGirl girl) noexcept
{
switch (girl) {
case RedHairedGirl::karen: return RedHairedGirl::hanne;
case RedHairedGirl::hanne: return RedHairedGirl::karen;
}
assert(!"Should not get here");
throw std::logic_error("Unknown girl");
}

std::string ribi::koer::ToStr(const BlackHairedGirl girl) noexcept
{
switch (girl) {
case BlackHairedGirl::kristel: return "Kristel";
case BlackHairedGirl::marthe: return "Marthe";
}
assert(!"Should not get here");
throw std::logic_error("Unknown girl");
}

std::string ribi::koer::ToStr(const BlondeGirl girl) noexcept
{
switch (girl) {
case BlondeGirl::kathleen: return "Kathleen";
case BlondeGirl::josje: return "Josje";
case BlondeGirl::klaasje: return "Klaasje";
}
assert(!"Should not get here");
throw std::logic_error("Unknown girl");
}

std::string ribi::koer::ToStr(const RedHairedGirl girl) noexcept
{
switch (girl) {
case RedHairedGirl::karen: return "Karen";
case RedHairedGirl::hanne: return "Hanne";
}
assert(!"Should not get here");
throw std::logic_error("Unknown girl");
}

25 changes: 25 additions & 0 deletions k3opeenrijnames.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
#ifndef K3OPEENRIJNAMES_H
#define K3OPEENRIJNAMES_H

#include <string>

namespace ribi {
namespace koer {

enum class BlackHairedGirl { kristel, marthe };
enum class BlondeGirl { kathleen, josje, klaasje };
enum class RedHairedGirl { karen, hanne };

BlackHairedGirl GetNext(const BlackHairedGirl girl) noexcept;
BlondeGirl GetNext(const BlondeGirl girl) noexcept;
RedHairedGirl GetNext(const RedHairedGirl girl) noexcept;

std::string ToStr(const BlackHairedGirl girl) noexcept;
std::string ToStr(const BlondeGirl girl) noexcept;
std::string ToStr(const RedHairedGirl girl) noexcept;

} //~namespace koer
} //~namespace ribi


#endif // K3OPEENRIJNAMES_H
2 changes: 1 addition & 1 deletion main.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -5,5 +5,5 @@
int main(int argc, char * argv[])
{
const std::vector<std::string> args { ribi::MenuDialog::ConvertArguments(argc,argv) };
return ribi::K3OpEenRijMenuDialog().Execute(args);
return ribi::koer::MenuDialog().Execute(args);
}
4 changes: 2 additions & 2 deletions qtk3opeenrijinstructionsdialog.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -4,14 +4,14 @@
#include "ui_qtk3opeenrijinstructionsdialog.h"
#pragma GCC diagnostic pop

ribi::QtK3OpEenRijInstructionsDialog::QtK3OpEenRijInstructionsDialog(QWidget *parent) noexcept
ribi::koer::QtK3OpEenRijInstructionsDialog::QtK3OpEenRijInstructionsDialog(QWidget *parent) noexcept
: QtHideAndShowDialog(parent),
ui(new Ui::QtK3OpEenRijInstructionsDialog)
{
ui->setupUi(this);
}

ribi::QtK3OpEenRijInstructionsDialog::~QtK3OpEenRijInstructionsDialog() noexcept
ribi::koer::QtK3OpEenRijInstructionsDialog::~QtK3OpEenRijInstructionsDialog() noexcept
{
delete ui;
}
Loading

0 comments on commit 625d2d8

Please sign in to comment.