You cannot select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
3775 lines
199 KiB
C#
3775 lines
199 KiB
C#
using System;
|
|
using System.Collections.Generic;
|
|
using System.Linq;
|
|
using System.Text;
|
|
using System.Threading.Tasks;
|
|
|
|
|
|
namespace Übungen_Anwendungsentwicklung
|
|
{
|
|
class Program
|
|
{
|
|
static void Main(string[] args)
|
|
{
|
|
//Deklaration
|
|
int AUSW;
|
|
bool Closer = false;
|
|
|
|
//Menü Auswahl
|
|
while (Closer == false)
|
|
{
|
|
Console.Clear();
|
|
Console.WriteLine("------------------------Uebungen-Anwendungsentwicklung----------------------");
|
|
Console.WriteLine("- (C) ADG 2016 -");
|
|
Console.WriteLine("- 1 = Kostenberechnung fuer Mietwagen -");
|
|
Console.WriteLine("- 2 = Mehrfachverzweigung Noten zu Text -");
|
|
Console.WriteLine("- 3 = Mehrfachverzweigung für Noten via If-Else Verschachtelung -");
|
|
Console.WriteLine("- 4 = Dienstwagenrechner -");
|
|
Console.WriteLine("- 5 = Versandkostenrechner -");
|
|
Console.WriteLine("- 6 = Teiler ermitteln -");
|
|
Console.WriteLine("- 7 = Wertetabelle ausgeben -");
|
|
Console.WriteLine("- 8 = Gewinnschwelle berechnen -");
|
|
Console.WriteLine("- 9 = Rekursion -");
|
|
Console.WriteLine("- 10= Polymorphie Übung -");
|
|
Console.WriteLine("- 11= Assoziations/Aggregations Übung Vater Kind -");
|
|
Console.WriteLine("- 12= Assoziations/Aggregations Übung Kunde Buch -");
|
|
Console.WriteLine("- 13= Statemachineübung -");
|
|
Console.WriteLine("----------------------------------------------------------------------------\n\n");
|
|
|
|
Console.Write("Ihre Auswahl(99 zum Beenden): ");
|
|
AUSW = Convert.ToInt32(Console.ReadLine());
|
|
|
|
//Auswahlswitch
|
|
switch (AUSW)
|
|
{
|
|
case 1: Mietwagenkosten(); break;
|
|
case 2: mehrfachverzweigung(); break;
|
|
case 3: mehrfachIf(); break;
|
|
case 4: dienstWagenRechner(); break;
|
|
case 5: versandkostenRechner(); break;
|
|
case 6: teilerErmitteln();break;
|
|
case 7: werttabelle();break;
|
|
case 8: gewinnschwelle();break;
|
|
//case 9: rekursion(); break;
|
|
case 10: polymorphie();break;
|
|
case 11: assoziaaggre();break;
|
|
case 12: assoziaaggre2(); break;
|
|
case 13: stateMachine(); break;
|
|
case 777: Arcade(); break;
|
|
case 99: Closer = true; break;
|
|
default: Console.WriteLine("Kein gültiges Programm!"); break;
|
|
};
|
|
};
|
|
|
|
}
|
|
|
|
public enum state
|
|
{
|
|
z1,
|
|
z2,
|
|
z3,
|
|
z4,
|
|
zf
|
|
}
|
|
|
|
|
|
static void stateMachine()
|
|
{
|
|
state q = state.z1;
|
|
string eingabe;
|
|
int dezimalGesWert = 0;
|
|
Console.Clear();
|
|
Console.WriteLine("----------------------------State Machine Übungen---------------------------");
|
|
Console.WriteLine("- (C) ADG 2017 -");
|
|
Console.WriteLine("- -");
|
|
Console.WriteLine("- Geben Sie einen Hexadezimal-String ein: -");
|
|
Console.WriteLine("- -");
|
|
Console.WriteLine("----------------------------------------------------------------------------");
|
|
|
|
eingabe = Console.ReadLine();
|
|
|
|
for(int index = 0; q != state.z4 || index >= 30/* EndlosschreifenSicherung*/; index++)
|
|
{
|
|
String hexWert = eingabe.Substring(index,1);
|
|
int asciiWert = 0;
|
|
|
|
foreach (char hex in hexWert)
|
|
{
|
|
asciiWert = (int)hex;
|
|
}
|
|
|
|
switch (q)
|
|
{
|
|
case state.z1:
|
|
//Abrage nach ","
|
|
if (asciiWert == 44)
|
|
{
|
|
q = state.z2;
|
|
};
|
|
//Abfrage erlaubt Wertebereich A-F,0-9
|
|
if ((asciiWert > 47 && asciiWert < 58)
|
|
|| asciiWert > 64 && asciiWert < 71)
|
|
{
|
|
//Addieren des dezimalwertes
|
|
switch(asciiWert)
|
|
{
|
|
case 65: dezimalGesWert += 10; break;
|
|
case 66: dezimalGesWert += 11; break;
|
|
case 67: dezimalGesWert += 12; break;
|
|
case 68: dezimalGesWert += 13; break;
|
|
case 69: dezimalGesWert += 14; break;
|
|
default:
|
|
dezimalGesWert += asciiWert - 65; break;
|
|
}
|
|
q = state.z3;
|
|
|
|
}
|
|
else
|
|
{
|
|
q = state.zf;
|
|
};
|
|
|
|
break;
|
|
case state.z2:
|
|
//Abfrage erlaubt Wertebereich A-Z,a-z,0-9 und einige Sonderzeichen
|
|
if ((asciiWert > 48 && asciiWert < 57)
|
|
|| asciiWert > 65 && asciiWert < 70)
|
|
{
|
|
q = state.z3;
|
|
}
|
|
else
|
|
{
|
|
q = state.zf;
|
|
};
|
|
break;
|
|
case state.z3:
|
|
//Abrage nach ","
|
|
if (asciiWert == 44)
|
|
{
|
|
q = state.z1;
|
|
};
|
|
//Abrage nach "."
|
|
if (asciiWert == 46)
|
|
{
|
|
q = state.z4;
|
|
}
|
|
break;
|
|
case state.z4: break;
|
|
case state.zf:
|
|
//Abrage nach ","
|
|
if (asciiWert == 44)
|
|
{
|
|
q = state.z1;
|
|
};
|
|
//Abrage nach "."
|
|
if (asciiWert == 46)
|
|
{
|
|
q = state.z4;
|
|
};
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
static void assoziaaggre()
|
|
{
|
|
// Vater Objekte
|
|
Vater Oswald = new Vater();
|
|
Oswald.name = "Oswald";
|
|
Vater Timo = new Vater();
|
|
Timo.name = "Timo";
|
|
|
|
//Kind Objekte
|
|
Kind Petra = new Kind(Oswald);
|
|
Petra.name = "Petra";
|
|
Kind Kevin = new Kind(Timo);
|
|
Kevin.name = "Kevin";
|
|
|
|
Console.WriteLine("Vater von " + Petra.name + "ist " + Petra.meinVater.name);
|
|
Console.WriteLine("Vater von " + Petra.name + "ist " + Petra.meinVater.name);
|
|
|
|
Console.WriteLine("Vater von " + Petra.name + "ist " + Petra.meinVater.name);
|
|
Console.WriteLine("Vater von " + Petra.name + "ist " + Petra.meinVater.name);
|
|
|
|
Console.ReadLine();
|
|
}
|
|
static void assoziaaggre2()
|
|
{
|
|
// Kunde Objekte
|
|
Vater Oswald = new Vater();
|
|
Oswald.name = "Oswald";
|
|
Vater Timo = new Vater();
|
|
Timo.name = "Timo";
|
|
|
|
//Buch Objekte
|
|
Kind Petra = new Kind(Oswald);
|
|
Petra.name = "Petra";
|
|
Kind Kevin = new Kind(Timo);
|
|
Kevin.name = "Kevin";
|
|
|
|
Console.WriteLine("Vater von " + Petra.name + "ist " + Petra.meinVater.name);
|
|
Console.WriteLine("Vater von " + Petra.name + "ist " + Petra.meinVater.name);
|
|
|
|
Console.WriteLine("Vater von " + Petra.name + "ist " + Petra.meinVater.name);
|
|
Console.WriteLine("Vater von " + Petra.name + "ist " + Petra.meinVater.name);
|
|
|
|
Console.ReadLine();
|
|
}
|
|
|
|
static void polymorphie()
|
|
{
|
|
|
|
}
|
|
static void gewinnschwelle()
|
|
{
|
|
int AUSW;
|
|
bool Closer = false;
|
|
int stueck = 0;
|
|
long profit = -200000;
|
|
long kosten = 200000;
|
|
bool begin = true;
|
|
bool breakEven = false;
|
|
int breakEvenStueck = 0;
|
|
|
|
const int einzelPreis = 100;
|
|
const int einzelKosten = 50;
|
|
//Bildschirm
|
|
while (Closer == false)
|
|
{
|
|
Console.Clear();
|
|
Console.WriteLine("------------------------------Gewinnschwelle berechnen----------------------");
|
|
Console.WriteLine("- Bei 100Euro pro Stueck und Prod.kosten von 50Euro pro Stueck -");
|
|
if (!begin)
|
|
{
|
|
Console.WriteLine("- -");
|
|
Console.WriteLine("- Stueckzahl Gesamtkosten Gesamtprofit -");
|
|
for (; stueck <= 6000; stueck++)
|
|
{
|
|
kosten += einzelKosten;
|
|
profit = profit +(einzelPreis - kosten);
|
|
Console.WriteLine("- " + stueck+ " "+kosten+" "+profit);
|
|
if ( profit > 0 && !breakEven)
|
|
{
|
|
breakEven = true;
|
|
breakEvenStueck = stueck;
|
|
}
|
|
}
|
|
Console.WriteLine("- -");
|
|
Console.WriteLine("- Break-Even Punkt bei "+breakEvenStueck+" erreicht!");
|
|
Console.WriteLine("- -");
|
|
Console.WriteLine("----------------------------------------------------------------------------\n\n");
|
|
}
|
|
else
|
|
{
|
|
Console.WriteLine("- -");
|
|
Console.WriteLine("- -");
|
|
Console.WriteLine("----------------------------------------------------------------------------\n\n");
|
|
}
|
|
begin = false;
|
|
Console.Write("(-1 zum Beenden/0 für beginnen): ");
|
|
AUSW = Convert.ToInt32(Console.ReadLine());
|
|
|
|
|
|
if (AUSW == -1 )
|
|
{
|
|
Closer = true;
|
|
}
|
|
}
|
|
}
|
|
static void werttabelle()
|
|
{
|
|
bool Closer = false;
|
|
int AUSW = 0;
|
|
double y_werte = 0.0;
|
|
while (Closer == false)
|
|
{
|
|
Console.Clear();
|
|
Console.WriteLine("--------------------------------Wertetabelle ausgeben-----------------------");
|
|
Console.WriteLine("- -");
|
|
Console.WriteLine("- Folgende Wertetabelle gilt fuer die Funktion: y = sin(x) * e^-x -");
|
|
Console.WriteLine("- Der Wertebereich wird angezeigt von x = 0 bis x = 3.2 -");
|
|
Console.WriteLine("- -");
|
|
Console.WriteLine("- X Y -");
|
|
for( double x_werte = 0.0; x_werte <6.3; x_werte += 0.1)
|
|
{
|
|
y_werte = Math.Sin(x_werte) * Math.Exp(-x_werte);
|
|
Console.WriteLine("- " + x_werte + " " + y_werte);
|
|
}
|
|
|
|
Console.WriteLine("- -");
|
|
Console.WriteLine("----------------------------------------------------------------------------\n\n");
|
|
|
|
Console.Write("(-1 zum Beenden): ");
|
|
AUSW = Convert.ToInt32(Console.ReadLine());
|
|
if (AUSW == -1)
|
|
Closer = true;
|
|
}
|
|
}
|
|
static void teilerErmitteln()
|
|
{
|
|
int AUSW = 0;
|
|
int erg = 0;
|
|
|
|
|
|
bool primzahl = false;
|
|
bool begin = true;
|
|
|
|
bool Closer = false;
|
|
|
|
//Hauptwahlscreen
|
|
while (Closer == false)
|
|
{
|
|
Console.Clear();
|
|
Console.WriteLine("-----------------------------------Teiler Ermitteln-------------------------");
|
|
Console.WriteLine("- -");
|
|
Console.WriteLine("- -");
|
|
if (begin)
|
|
{
|
|
Console.WriteLine("- -");
|
|
Console.WriteLine("----------------------------------------------------------------------------\n\n");
|
|
}
|
|
else if (primzahl)
|
|
{
|
|
Console.Clear();
|
|
Console.WriteLine("-----------------------------------Teiler Ermitteln-------------------------");
|
|
Console.WriteLine("- -");
|
|
Console.WriteLine("- -");
|
|
Console.WriteLine("- Die Zahl: "+AUSW+" ist eine Primzahl! ");
|
|
Console.WriteLine("- -");
|
|
Console.WriteLine("----------------------------------------------------------------------------\n\n");
|
|
primzahl = false;
|
|
}
|
|
else
|
|
{
|
|
Console.WriteLine("- Die Folgenden Zahlen sind Teiler von "+AUSW+" : ");
|
|
|
|
for (int i = 1; i <= AUSW; i++)
|
|
{
|
|
|
|
if(AUSW % i == 0)
|
|
{
|
|
|
|
erg += i;
|
|
if (erg - 1 == AUSW)
|
|
{
|
|
primzahl = true;
|
|
|
|
}
|
|
Console.WriteLine("- " + i);
|
|
if (i % 12 == 0)
|
|
{
|
|
Console.WriteLine();
|
|
|
|
}
|
|
}
|
|
|
|
}
|
|
Console.WriteLine("- -");
|
|
Console.WriteLine("----------------------------------------------------------------------------\n\n");
|
|
}
|
|
if (primzahl)
|
|
{
|
|
|
|
continue;
|
|
|
|
}
|
|
Console.Write("Geben Sie die zu Ueberpruefende Zahl ein (-1 zum Beenden): ");
|
|
AUSW = Convert.ToInt32(Console.ReadLine());
|
|
begin = false;
|
|
erg = 0;
|
|
if (AUSW == -1)
|
|
Closer = true;
|
|
|
|
}
|
|
|
|
}
|
|
static void versandkostenRechner()
|
|
{
|
|
bool Closer = false;
|
|
|
|
int unterlagen = -1;
|
|
int lieferart = -1;
|
|
int rechnung = -1;
|
|
string sondertext = " ";
|
|
|
|
string lieferartText = " ";
|
|
|
|
//Menü Auswahl
|
|
while (Closer == false)
|
|
{
|
|
Console.Clear();
|
|
Console.WriteLine("------------------------Versandkostenrechner--------------------------------");
|
|
Console.WriteLine("- (C) ADG 2016 -");
|
|
Console.WriteLine("- Berechnung von Versandkosten fuer Standart und Expresslieferung -");
|
|
Console.WriteLine("- -");
|
|
if (unterlagen < 0 && lieferart < 0)
|
|
{
|
|
Console.WriteLine("- -");
|
|
Console.WriteLine("- Lieferarten: 1 = Standart | 2 = Express -");
|
|
Console.WriteLine("- -");
|
|
Console.WriteLine("- -");
|
|
|
|
}
|
|
else
|
|
{
|
|
Console.WriteLine("- Anzahl Unterlagen : " + unterlagen);
|
|
Console.WriteLine("- Gewaehlte Lieferart: " + lieferart);
|
|
Console.WriteLine("- " + lieferartText);
|
|
if (sondertext != " ")
|
|
Console.WriteLine("- " + sondertext);
|
|
else
|
|
Console.WriteLine("- Rechnung : " + rechnung);
|
|
|
|
}
|
|
Console.WriteLine("- -");
|
|
Console.WriteLine("----------------------------------------------------------------------------\n\n");
|
|
|
|
if (unterlagen < 0 && lieferart < 0)
|
|
{
|
|
Console.Write("Geben Sie die Anzahl der Unterlagen ein: ");
|
|
unterlagen = Convert.ToInt32(Console.ReadLine());
|
|
Console.Write("Geben Sie die Lieferart : ");
|
|
lieferart = Convert.ToInt32(Console.ReadLine());
|
|
|
|
if (lieferart == 1)
|
|
lieferartText = "Standart";
|
|
else if (lieferart == 2)
|
|
lieferartText = "Express";
|
|
else
|
|
lieferartText = "Ungueltige Eingabe";
|
|
|
|
if (lieferartText != "Ungueltige Eingabe")
|
|
{
|
|
if (lieferart == 1)
|
|
{
|
|
if (unterlagen < 2)
|
|
rechnung = 3;
|
|
else
|
|
rechnung = 0;
|
|
}
|
|
if (lieferart == 2)
|
|
{
|
|
if (unterlagen <= 2)
|
|
rechnung = 22;
|
|
else if (unterlagen <= 40)
|
|
rechnung = 19;
|
|
else if (unterlagen <= 80)
|
|
rechnung = 38;
|
|
else if (unterlagen <= 120)
|
|
rechnung = 57;
|
|
else
|
|
sondertext = "auf Anfrage";
|
|
}
|
|
}
|
|
else
|
|
{
|
|
lieferart = -1;
|
|
unterlagen = -1;
|
|
}
|
|
|
|
}
|
|
else
|
|
{
|
|
Console.ReadLine();
|
|
Closer = true;
|
|
}
|
|
};
|
|
}
|
|
static void dienstWagenRechner()
|
|
{
|
|
int gef_Km = -1;
|
|
int verbrauch = -1;
|
|
int nutzungStunden = -1;
|
|
|
|
double dschnittVerbauch = -1.0;
|
|
int prozentTagesnutzung = -1;
|
|
bool Closer = false;
|
|
|
|
//Menü Auswahl
|
|
while (Closer == false)
|
|
{
|
|
Console.Clear();
|
|
Console.WriteLine("------------------------Dienstwagenberechner--------------------------------");
|
|
Console.WriteLine("- (C) ADG 2016 -");
|
|
Console.WriteLine("- Berechnung von Durchschnittsverbrauch und -zeitliche Nutzung -");
|
|
Console.WriteLine("- -");
|
|
if (gef_Km < 0 && verbrauch < 0 && nutzungStunden < 0)
|
|
{
|
|
Console.WriteLine("- -");
|
|
Console.WriteLine("- -");
|
|
Console.WriteLine("- -");
|
|
Console.WriteLine("- -");
|
|
Console.WriteLine("- -");
|
|
Console.WriteLine("- -");
|
|
}
|
|
else
|
|
{
|
|
Console.WriteLine("- Gefahrene Kilometer : " + gef_Km);
|
|
Console.WriteLine("- Verbrauchte Liter Treibstoff : " + verbrauch);
|
|
Console.WriteLine("- Genutzte Stunden : " + nutzungStunden);
|
|
Console.WriteLine("- -");
|
|
Console.WriteLine("- Durchschnittsverbrauch (in L pro 100 Km): " + dschnittVerbauch);
|
|
Console.WriteLine("- Prozentuale zeitliche Nutzung : " + prozentTagesnutzung + " %");
|
|
}
|
|
Console.WriteLine("- -");
|
|
Console.WriteLine("----------------------------------------------------------------------------\n\n");
|
|
|
|
if (gef_Km < 0 && verbrauch < 0 && nutzungStunden < 0)
|
|
{
|
|
Console.Write("Geben Sie die gefahren Kilometer fuer diesen Tag ein: ");
|
|
gef_Km = Convert.ToInt32(Console.ReadLine());
|
|
Console.Write("Geben Sie die den Verbrauch an Treibstoff fuer diesen Tag ein: ");
|
|
verbrauch = Convert.ToInt32(Console.ReadLine());
|
|
Console.Write("Geben Sie die genutzten Zeitstunden fuer diesen Tag ein: ");
|
|
nutzungStunden = Convert.ToInt32(Console.ReadLine());
|
|
|
|
//Berechnung Dschnitt und Prozentuale Nutzung
|
|
dschnittVerbauch = Convert.ToDouble(verbrauch) * 100 / Convert.ToDouble(gef_Km);
|
|
prozentTagesnutzung = nutzungStunden * 100 / 8;
|
|
}
|
|
else
|
|
{
|
|
Console.ReadLine();
|
|
Closer = true;
|
|
}
|
|
};
|
|
}
|
|
static void mehrfachIf()
|
|
{
|
|
string noteText = " ";
|
|
int noteZahl = 0;
|
|
double noteProzent = -1;
|
|
|
|
bool Closer = false;
|
|
|
|
//Menü Auswahl
|
|
while (Closer == false)
|
|
{
|
|
|
|
Console.Clear();
|
|
Console.WriteLine("------------------------Mehrfachverzweigung---------------------------------");
|
|
Console.WriteLine("- (C) ADG 2016 -");
|
|
Console.WriteLine("- Umrechnung von Schulnoten von Prozent in rechnerische Note -");
|
|
Console.WriteLine("- -");
|
|
if (noteProzent < 0 && noteText == " ")
|
|
Console.WriteLine("- -");
|
|
else if (noteText == "Eingabefehler: Ungültige Eingabe")
|
|
Console.WriteLine("- " + noteText);
|
|
else
|
|
Console.WriteLine("- Rechnerische Note : " + noteZahl + " " + noteText);
|
|
Console.WriteLine("- -");
|
|
Console.WriteLine("----------------------------------------------------------------------------\n\n");
|
|
|
|
if (noteProzent < 0.0)
|
|
{
|
|
|
|
Console.Write("Geben Sie Ihre Punktzahl in erreichte Prozent ein: ");
|
|
noteProzent = Convert.ToDouble(Console.ReadLine());
|
|
|
|
//Zuweisung der Zahl zu Text
|
|
if (noteProzent > 98.0)
|
|
{
|
|
noteText = "Sehr Gut";
|
|
noteZahl = 1;
|
|
}
|
|
else if (noteProzent > 95.0)
|
|
{
|
|
noteText = "Sehr Gut";
|
|
noteZahl = 1;
|
|
}
|
|
else if (noteProzent > 92.0)
|
|
{
|
|
noteText = "Sehr Gut";
|
|
noteZahl = 1;
|
|
}
|
|
else if (noteProzent > 88.0)
|
|
{
|
|
noteText = "Gut";
|
|
noteZahl = 2;
|
|
}
|
|
else if (noteProzent > 82.0)
|
|
{
|
|
noteText = "Gut";
|
|
noteZahl = 2;
|
|
}
|
|
else if (noteProzent > 78.0)
|
|
{
|
|
noteText = "Gut";
|
|
noteZahl = 2;
|
|
}
|
|
else if (noteProzent > 73.0)
|
|
{
|
|
noteText = "Befriedigend";
|
|
noteZahl = 3;
|
|
}
|
|
else if (noteProzent > 67.0)
|
|
{
|
|
noteText = "Befriedigend";
|
|
noteZahl = 3;
|
|
}
|
|
else if (noteProzent > 62.0)
|
|
{
|
|
noteText = "Befriedigend";
|
|
noteZahl = 3;
|
|
}
|
|
else if (noteProzent > 57.0)
|
|
{
|
|
noteText = "Ausreichend";
|
|
noteZahl = 4;
|
|
}
|
|
else if (noteProzent > 50.0)
|
|
{
|
|
noteText = "Ausreichend";
|
|
noteZahl = 4;
|
|
}
|
|
else if (noteProzent > 45.0)
|
|
{
|
|
noteText = "Ausreichend";
|
|
noteZahl = 4;
|
|
}
|
|
else if (noteProzent > 37.0)
|
|
{
|
|
noteText = "Mangelhaft";
|
|
noteZahl = 5;
|
|
}
|
|
else if (noteProzent > 29.0)
|
|
{
|
|
noteText = "Mangelhaft";
|
|
noteZahl = 5;
|
|
}
|
|
else if (noteProzent > 21.0)
|
|
{
|
|
noteText = "Mangelhaft";
|
|
noteZahl = 5;
|
|
}
|
|
else if (noteProzent > 0.0)
|
|
{
|
|
noteText = "Ungenügend";
|
|
noteZahl = 6;
|
|
}
|
|
else
|
|
{
|
|
noteText = "Eingabefehler: Ungültige Eingabe";
|
|
}
|
|
|
|
}
|
|
else
|
|
{
|
|
Console.ReadLine();
|
|
Closer = true;
|
|
}
|
|
}
|
|
}
|
|
static void mehrfachverzweigung()
|
|
{
|
|
int noteZahl = -1;
|
|
string noteText = " ";
|
|
|
|
bool Closer = false;
|
|
|
|
//Menü Auswahl
|
|
while (Closer == false)
|
|
{
|
|
Console.Clear();
|
|
Console.WriteLine("------------------------Mehrfachverzweigung---------------------------------");
|
|
Console.WriteLine("- (C) ADG 2016 -");
|
|
Console.WriteLine("- Umrechnung von Schulnoten von Zahlenform in Textform -");
|
|
Console.WriteLine("- -");
|
|
if (noteZahl < 0)
|
|
Console.WriteLine("- -");
|
|
else
|
|
Console.WriteLine("- Note : " + noteZahl + " " + noteText + " ");
|
|
Console.WriteLine("- -");
|
|
Console.WriteLine("----------------------------------------------------------------------------\n\n");
|
|
|
|
if (noteZahl < 0)
|
|
{
|
|
Console.Write("Geben Sie Ihre Note als Zahk ein: ");
|
|
noteZahl = Convert.ToInt32(Console.ReadLine());
|
|
|
|
//Zuweisung der Zahl zu Text
|
|
switch (noteZahl)
|
|
{
|
|
case 1: noteText = "Sehr Gut"; break;
|
|
case 2: noteText = "Gut"; break;
|
|
case 3: noteText = "Befriedigend"; break;
|
|
case 4: noteText = "Ausreichend"; break;
|
|
case 5: noteText = "Mangelhaft"; break;
|
|
case 6: noteText = "Ungenügend"; break;
|
|
default: noteText = "Eingabefehler: Ungültige Eingabe"; break;
|
|
}
|
|
}
|
|
else
|
|
{
|
|
Console.ReadLine();
|
|
Closer = true;
|
|
}
|
|
};
|
|
}
|
|
|
|
static void Mietwagenkosten()
|
|
{
|
|
//Deklarationen
|
|
|
|
//boolscher Wert für Hauptschleife
|
|
bool beendet = false;
|
|
//Genutze Werktage
|
|
int t_werk = -1;
|
|
//Genutzte Wochenendtage
|
|
int t_we = -1;
|
|
//gefahrene KM
|
|
int gef_km = -1;
|
|
//Mietpreis Werktags
|
|
const int mietpreis_werk = 75;
|
|
//Mietpreis Wochenends
|
|
const int mietpreis_we = 100;
|
|
//FreiKM Werktags
|
|
const int freiKM_werk = 100;
|
|
//FreiKM Wochenends
|
|
const int freiKM_we = 200;
|
|
//Kosten pro mehrKM werktags
|
|
const double mehrpreisKM_werk = 0.35;
|
|
|
|
//Ergebnisvariablen
|
|
int insg_freiKM = 0;
|
|
int mehrKM = 0;
|
|
double ges_miete = 0;
|
|
double rechnung = 0;
|
|
|
|
while (!beendet)
|
|
{
|
|
|
|
//Bildschirm
|
|
Console.Clear();
|
|
Console.WriteLine("------------------------Mietwagenkosten-Rechner-----------------------------");
|
|
Console.WriteLine("- (C) ADG 2016 ");
|
|
Console.WriteLine("- ");
|
|
if (t_werk >= 0 && t_we >= 0 && gef_km >= 0)
|
|
{
|
|
Console.WriteLine("- Arbeitstage : " + t_werk + " Tage ");
|
|
Console.WriteLine("- Wochenendtage : " + t_we + " Tage ");
|
|
Console.WriteLine("- gefahrene KM : " + gef_km + " KM ");
|
|
Console.WriteLine("- ");
|
|
Console.WriteLine("- ");
|
|
Console.WriteLine("- ");
|
|
Console.WriteLine("- insg. freiKM : " + insg_freiKM + " KM ");
|
|
Console.WriteLine("- mehr KM : " + mehrKM + " KM ");
|
|
Console.WriteLine("- insg. Miete : " + ges_miete + " Euro ");
|
|
Console.WriteLine("- ");
|
|
Console.WriteLine("- ");
|
|
Console.WriteLine("- Rechnung : " + rechnung + " Euro ");
|
|
}
|
|
else
|
|
{
|
|
Console.WriteLine("- Arbeitstage : ");
|
|
Console.WriteLine("- Wochenendtage : ");
|
|
Console.WriteLine("- gefahrene KM : ");
|
|
Console.WriteLine("- ");
|
|
Console.WriteLine("- ");
|
|
Console.WriteLine("- ");
|
|
Console.WriteLine("- insg. freiKM : ");
|
|
Console.WriteLine("- mehr KM : ");
|
|
Console.WriteLine("- insg. Miete : ");
|
|
Console.WriteLine("- ");
|
|
Console.WriteLine("- ");
|
|
Console.WriteLine("- Rechnung : ");
|
|
}
|
|
|
|
|
|
Console.WriteLine("- ");
|
|
Console.WriteLine("- ");
|
|
Console.WriteLine("- ");
|
|
Console.WriteLine("- ");
|
|
Console.WriteLine("----------------------------------------------------------------------------\n\n");
|
|
if (t_werk < 0 && t_we < 0 && gef_km < 0)
|
|
{
|
|
Console.Write("Wie viele Arbeitstage wurden gemietet: ");
|
|
t_werk = Convert.ToInt32(Console.ReadLine());
|
|
|
|
Console.Write("Wie viele Wochenendtage wurden gemietet: ");
|
|
t_we = Convert.ToInt32(Console.ReadLine());
|
|
|
|
Console.Write("Wie viele KM wurden gefahren: ");
|
|
gef_km = Convert.ToInt32(Console.ReadLine());
|
|
|
|
//Berechnung
|
|
|
|
insg_freiKM = t_werk * freiKM_werk + t_we * freiKM_we;
|
|
mehrKM = gef_km - insg_freiKM;
|
|
ges_miete = mietpreis_werk * t_werk + mietpreis_we * t_we;
|
|
rechnung = ges_miete + ((gef_km - (t_werk * freiKM_werk) - (t_we * freiKM_we)) * mehrpreisKM_werk);
|
|
|
|
|
|
}
|
|
else
|
|
{
|
|
Console.ReadLine();
|
|
beendet = true;
|
|
}
|
|
}
|
|
}
|
|
|
|
/*static void rekursion()
|
|
{
|
|
//Deklarationen
|
|
|
|
//boolscher Wert für Hauptschleife
|
|
bool beendet = false;
|
|
|
|
|
|
while (!beendet)
|
|
{
|
|
|
|
//Bildschirm
|
|
Console.Clear();
|
|
Console.WriteLine("----------------------------Rekursion--------------------------------------");
|
|
Console.WriteLine("- (C) ADG 2017 ");
|
|
Console.WriteLine("- ");
|
|
if (>= 0 && t_we >= 0 && gef_km >= 0)
|
|
{
|
|
Console.WriteLine("- Arbeitstage : " + t_werk + " Tage ");
|
|
Console.WriteLine("- Wochenendtage : " + t_we + " Tage ");
|
|
Console.WriteLine("- gefahrene KM : " + gef_km + " KM ");
|
|
Console.WriteLine("- ");
|
|
Console.WriteLine("- ");
|
|
Console.WriteLine("- ");
|
|
Console.WriteLine("- insg. freiKM : " + insg_freiKM + " KM ");
|
|
Console.WriteLine("- mehr KM : " + mehrKM + " KM ");
|
|
Console.WriteLine("- insg. Miete : " + ges_miete + " Euro ");
|
|
Console.WriteLine("- ");
|
|
Console.WriteLine("- ");
|
|
Console.WriteLine("- Rechnung : " + rechnung + " Euro ");
|
|
}
|
|
else
|
|
{
|
|
Console.WriteLine("- Arbeitstage : ");
|
|
Console.WriteLine("- Wochenendtage : ");
|
|
Console.WriteLine("- gefahrene KM : ");
|
|
Console.WriteLine("- ");
|
|
Console.WriteLine("- ");
|
|
Console.WriteLine("- ");
|
|
Console.WriteLine("- insg. freiKM : ");
|
|
Console.WriteLine("- mehr KM : ");
|
|
Console.WriteLine("- insg. Miete : ");
|
|
Console.WriteLine("- ");
|
|
Console.WriteLine("- ");
|
|
Console.WriteLine("- Rechnung : ");
|
|
}
|
|
|
|
|
|
Console.WriteLine("- ");
|
|
Console.WriteLine("- ");
|
|
Console.WriteLine("- ");
|
|
Console.WriteLine("- ");
|
|
Console.WriteLine("----------------------------------------------------------------------------\n\n");
|
|
if (t_werk < 0 && t_we < 0 && gef_km < 0)
|
|
{
|
|
Console.Write("Wie viele Arbeitstage wurden gemietet: ");
|
|
t_werk = Convert.ToInt32(Console.ReadLine());
|
|
|
|
Console.Write("Wie viele Wochenendtage wurden gemietet: ");
|
|
t_we = Convert.ToInt32(Console.ReadLine());
|
|
|
|
Console.Write("Wie viele KM wurden gefahren: ");
|
|
gef_km = Convert.ToInt32(Console.ReadLine());
|
|
|
|
//Berechnung
|
|
|
|
insg_freiKM = t_werk * freiKM_werk + t_we * freiKM_we;
|
|
mehrKM = gef_km - insg_freiKM;
|
|
ges_miete = mietpreis_werk * t_werk + mietpreis_we * t_we;
|
|
rechnung = ges_miete + ((gef_km - (t_werk * freiKM_werk) - (t_we * freiKM_we)) * mehrpreisKM_werk);
|
|
|
|
|
|
}
|
|
else
|
|
{
|
|
Console.ReadLine();
|
|
beendet = true;
|
|
}
|
|
}
|
|
}*/
|
|
|
|
static void Arcade()
|
|
{
|
|
int AUSW = 0;
|
|
bool Closer = false;
|
|
|
|
//Hauptwahlscreen
|
|
while (Closer == false)
|
|
{
|
|
Console.Clear();
|
|
Console.WriteLine("-----------------------------------ARCADE-----------------------------------");
|
|
Console.WriteLine("- -");
|
|
Console.WriteLine("- Welches Spiel möchten Sie Spielen? -");
|
|
Console.WriteLine("- -");
|
|
Console.WriteLine("- 1 = Russisch Roulette -");
|
|
Console.WriteLine("- 2 = 100er Ratespiel (nicht Implementiert) -");
|
|
Console.WriteLine("- 3 = Tic Tac Toe (nicht Implementiert) -");
|
|
Console.WriteLine("- 4 = 4 Gewinnt (nicht Implementiert) -");
|
|
Console.WriteLine("- 5 = Mastermind (nicht Implementiert) -");
|
|
Console.WriteLine("- 6 = Schiffe versenken (nicht Implementiert) -");
|
|
Console.WriteLine("- 7 = Bingo (nicht Implementiert) -");
|
|
Console.WriteLine("- 8 = Solitair (nicht Implementiert) -");
|
|
Console.WriteLine("- 9 = Othello (nicht komplett Implementiert) -");
|
|
Console.WriteLine("- 10 = Hangman (nicht Implementiert) -");
|
|
Console.WriteLine("- -");
|
|
Console.WriteLine("----------------------------------------------------------------------------\n\n");
|
|
|
|
Console.Write("Ihre Auswahl(99 zum Beenden): ");
|
|
AUSW = Convert.ToInt32(Console.ReadLine());
|
|
|
|
//Spiele Auswahl
|
|
switch (AUSW)
|
|
{
|
|
case 9: Othello(); break;
|
|
case 1: RussianRoulette(); break;
|
|
case 99: Closer = true; break;
|
|
default: Console.WriteLine("Kein gültiges Programm!"); break;
|
|
};
|
|
};
|
|
|
|
}
|
|
|
|
static void RussianRoulette()
|
|
{
|
|
int AUSW = 0;
|
|
bool Closer = false;
|
|
|
|
//marker für benutzte Schächte
|
|
|
|
bool[] benutzt = new bool[9] { false, false, false, false, false, false, false, false, false };
|
|
|
|
//Modus 0 = Default
|
|
// 1 = SchachtWahl
|
|
// 2 = Spielende/Loose
|
|
// 3 = Spielende/Win
|
|
int gameMode = 0;
|
|
|
|
|
|
int wahlSchacht = 0;
|
|
|
|
Random randomizer = new Random((int)System.DateTime.Now.ToFileTime());
|
|
int kugelschacht = randomizer.Next(1, 8);
|
|
|
|
|
|
//bool spielEnde = false;
|
|
int zwangswahl;
|
|
|
|
|
|
//Anzahl versuche
|
|
zwangswahl = 6;
|
|
while (Closer == false)
|
|
{
|
|
Console.Clear();
|
|
#region Oberer Infoscreen
|
|
Console.WriteLine("----------------------------Russian Roulette--------------------------------");
|
|
Console.WriteLine("- (c)2008 A.Degen -");
|
|
Console.WriteLine("- Die Kugel befindet sich in einem von 8 Schaechten! -");
|
|
Console.WriteLine("- -");
|
|
Console.WriteLine("- .--. .. -");
|
|
Console.WriteLine("- .----. _| '---------------.______________.-'' } -");
|
|
Console.WriteLine("- '-. },' .---------. } ===== ====== }==. -");
|
|
Console.WriteLine("- --' || (_____|- = = |--------------------| | -");
|
|
Console.WriteLine("- / || _____| - -- - |____________________/ | -");
|
|
Console.WriteLine("- / || (_____| - -- - |____________________)==' -");
|
|
Console.WriteLine("- | '---------'_-- - / 2 -");
|
|
Console.WriteLine("- | . (_||== / ___ -");
|
|
#endregion
|
|
|
|
#region Schacht 2 Handling
|
|
if (gameMode == 1 && benutzt[2])
|
|
{
|
|
Console.WriteLine("- / .::. .---. _____/ ___/ x }___ -");
|
|
Console.WriteLine("- | :::::: .--. / }/ |( 1 / } / } 3 -");
|
|
}
|
|
else if (kugelschacht == 2 && (gameMode == 2 || gameMode == 3))
|
|
{
|
|
Console.WriteLine("- / .::. .---. _____/ ___/ 0 }___ -");
|
|
Console.WriteLine("- | :::::: .--. / }/ |( 1 / } / } 3 -");
|
|
}
|
|
else
|
|
{
|
|
Console.WriteLine("- / .::. .---. _____/ ___/ }___ -");
|
|
Console.WriteLine("- | :::::: .--. / }/ |( 1 / } / } 3 -");
|
|
}
|
|
#endregion
|
|
|
|
#region Schacht 1 und 3 Handling
|
|
if (gameMode == 1 && benutzt[1] && benutzt[3])
|
|
{
|
|
Console.WriteLine("- | :::::: / } | | // / x |'--'| x } -");
|
|
Console.WriteLine("- | :::::: | '-----' | }--/ === }__/| -");
|
|
}
|
|
else if (gameMode == 1 && benutzt[1] && !benutzt[3])
|
|
{
|
|
Console.WriteLine("- | :::::: / } | | // / x |'--'| } -");
|
|
Console.WriteLine("- | :::::: | '-----' | }--/ === }__/| -");
|
|
}
|
|
else if (gameMode == 1 && !benutzt[1] && benutzt[3])
|
|
{
|
|
Console.WriteLine("- | :::::: / } | | // / |'--'| x } -");
|
|
Console.WriteLine("- | :::::: | '-----' | }--/ === }__/| -");
|
|
}
|
|
else if (kugelschacht == 1 && (gameMode == 2 || gameMode == 3))
|
|
{
|
|
Console.WriteLine("- | :::::: / } | | // / 0 |'--'| } -");
|
|
Console.WriteLine("- | :::::: | '-----' | }--/ === }__/| -");
|
|
}
|
|
else if (kugelschacht == 3 && (gameMode == 2 || gameMode == 3))
|
|
{
|
|
Console.WriteLine("- | :::::: / } | | // / |'--'| 0 } -");
|
|
Console.WriteLine("- | :::::: | '-----' | }--/ === }__/| -");
|
|
}
|
|
else
|
|
{
|
|
Console.WriteLine("- | :::::: / } | | // / |'--'| } -");
|
|
Console.WriteLine("- | :::::: | '-----' | }--/ === }__/| -");
|
|
}
|
|
#endregion
|
|
|
|
#region Schacht 8 und 4 Handling
|
|
|
|
if (gameMode == 1 && benutzt[8] && benutzt[4])
|
|
{
|
|
Console.WriteLine("- / .:::::: | 8 |/ x }|(X)|/ x}| 4 -");
|
|
Console.WriteLine("- | ::::::: | |}___/ === }__/| -");
|
|
}
|
|
else if (gameMode == 1 && benutzt[8] && !benutzt[4])
|
|
{
|
|
Console.WriteLine("- / .:::::: | 8 |/ x }|(X)|/ }| 4 -");
|
|
Console.WriteLine("- | ::::::: | |}___/ === }__/| -");
|
|
}
|
|
else if (gameMode == 1 && !benutzt[8] && benutzt[4])
|
|
{
|
|
Console.WriteLine("- / .:::::: | 8 |/ }|(X)|/ x}| 4 -");
|
|
Console.WriteLine("- | ::::::: | |}___/ === }__/| -");
|
|
}
|
|
else if (kugelschacht == 8 && (gameMode == 2 || gameMode == 3))
|
|
{
|
|
Console.WriteLine("- / .:::::: | 8 |/ 0 }|(X)|/ }| 4 -");
|
|
Console.WriteLine("- | ::::::: | |}___/ === }__/| -");
|
|
}
|
|
else if (kugelschacht == 4 && (gameMode == 2 || gameMode == 3))
|
|
{
|
|
Console.WriteLine("- / .:::::: | 8 |/ }|(X)|/ 0}| 4 -");
|
|
Console.WriteLine("- | ::::::: | |}___/ === }__/| -");
|
|
}
|
|
else
|
|
{
|
|
Console.WriteLine("- / .:::::: | 8 |/ }|(X)|/ }| 4 -");
|
|
Console.WriteLine("- | ::::::: | |}___/ === }__/| -");
|
|
}
|
|
#endregion
|
|
|
|
#region Schacht 7 && 5 Handling
|
|
if (gameMode == 1 && benutzt[7] && benutzt[5])
|
|
{
|
|
Console.WriteLine("- | ::::::: | }/ x }/ }/ x}/ -");
|
|
}
|
|
else if (gameMode == 1 && benutzt[7] && !benutzt[5])
|
|
{
|
|
Console.WriteLine("- | ::::::: | }/ x }/ }/ }/ -");
|
|
}
|
|
else if (gameMode == 1 && !benutzt[7] && benutzt[5])
|
|
{
|
|
Console.WriteLine("- | ::::::: | }/ }/ }/ x}/ -");
|
|
}
|
|
else if (kugelschacht == 7 && (gameMode == 2 || gameMode == 3))
|
|
{
|
|
Console.WriteLine("- | ::::::: | }/ 0 }/ }/ }/ -");
|
|
}
|
|
else if (kugelschacht == 5 && (gameMode == 2 || gameMode == 3))
|
|
{
|
|
Console.WriteLine("- | ::::::: | }/ }/ }/ 0}/ -");
|
|
}
|
|
else
|
|
{
|
|
Console.WriteLine("- | ::::::: | }/ }/ }/ }/ -");
|
|
}
|
|
#endregion
|
|
|
|
#region Schacht 6 handling
|
|
if (gameMode == 1 && benutzt[6])
|
|
{
|
|
Console.WriteLine("- | .::::::: | 7 }____' x '___/ 5 -");
|
|
Console.WriteLine("- '-----------' }___/ -");
|
|
Console.WriteLine("- 6 -");
|
|
}
|
|
else if (kugelschacht == 6 && (gameMode == 2 || gameMode == 3))
|
|
{
|
|
Console.WriteLine("- | .::::::: | 7 }____' 0 '___/ 5 -");
|
|
Console.WriteLine("- '-----------' }___/ -");
|
|
Console.WriteLine("- 6 -");
|
|
}
|
|
else
|
|
{
|
|
Console.WriteLine("- | .::::::: | 7 }____' '___/ 5 -");
|
|
Console.WriteLine("- '-----------' }___/ -");
|
|
Console.WriteLine("- 6 -");
|
|
}
|
|
#endregion
|
|
|
|
#region Unterer Infoscreen
|
|
if (gameMode == 1)
|
|
{
|
|
Console.WriteLine("- Du must noch: " + zwangswahl + " mal einen Kugelschacht auswaehlen! -");
|
|
Console.WriteLine("- -");
|
|
Console.WriteLine("- Waehle deinen naechsten Schacht! -");
|
|
if (wahlSchacht != 0)
|
|
Console.WriteLine("- Deine letzte Wahl : " + wahlSchacht + " -");
|
|
else
|
|
Console.WriteLine("- -");
|
|
}
|
|
else
|
|
if (gameMode == 2)
|
|
{
|
|
Console.WriteLine("- -");
|
|
Console.WriteLine("- -");
|
|
Console.WriteLine("- Pech gehabt! Die Kugel hat Dich erwischt ! -");
|
|
Console.WriteLine("- Moechten Sie noch einmal spielen ? (0 =ja/-1 =nein) -");
|
|
}
|
|
else
|
|
if (gameMode == 3)
|
|
{
|
|
Console.WriteLine("- -");
|
|
Console.WriteLine("- -");
|
|
Console.WriteLine("- Glückspilz! Die Kugel war im Schacht " + kugelschacht + " ! -");
|
|
Console.WriteLine("- Moechten Sie noch einmal spielen ? (0 =ja/-1 =nein) -");
|
|
}
|
|
else
|
|
{
|
|
Console.WriteLine("- -");
|
|
Console.WriteLine("- Zum Spielstart 0 eingeben! -");
|
|
Console.WriteLine("- -");
|
|
Console.WriteLine("- -");
|
|
}
|
|
Console.WriteLine("- -");
|
|
Console.WriteLine("- -");
|
|
Console.WriteLine("----------------------------------------------------------------------------\n\n");
|
|
#endregion
|
|
|
|
Console.Write("Ihre Auswahl(-1 zum Beenden): ");
|
|
AUSW = Convert.ToInt32(Console.ReadLine());
|
|
|
|
switch (AUSW)
|
|
{
|
|
case 8: if (gameMode == 1 && benutzt[8] == false) { wahlSchacht = 8; benutzt[8] = true; zwangswahl--; }; break;
|
|
case 7: if (gameMode == 1 && benutzt[7] == false) { wahlSchacht = 7; benutzt[7] = true; zwangswahl--; }; break;
|
|
case 6: if (gameMode == 1 && benutzt[6] == false) { wahlSchacht = 6; benutzt[6] = true; zwangswahl--; }; break;
|
|
case 5: if (gameMode == 1 && benutzt[5] == false) { wahlSchacht = 5; benutzt[5] = true; zwangswahl--; }; break;
|
|
case 4: if (gameMode == 1 && benutzt[4] == false) { wahlSchacht = 4; benutzt[4] = true; zwangswahl--; }; break;
|
|
case 3: if (gameMode == 1 && benutzt[3] == false) { wahlSchacht = 3; benutzt[3] = true; zwangswahl--; }; break;
|
|
case 2: if (gameMode == 1 && benutzt[2] == false) { wahlSchacht = 2; benutzt[2] = true; zwangswahl--; }; break;
|
|
case 1: if (gameMode == 1 && benutzt[1] == false) { wahlSchacht = 1; benutzt[1] = true; zwangswahl--; }; break;
|
|
case 0: if (gameMode == 0 || gameMode == 2 || gameMode == 3) gameMode = 1; kugelschacht = randomizer.Next(1, 8); wahlSchacht = 0; break;
|
|
case -1: Closer = true; break;
|
|
default: Console.WriteLine("Keine gültige Auswahl!"); break;
|
|
};
|
|
|
|
if (zwangswahl == 0)
|
|
{
|
|
gameMode = 3;
|
|
zwangswahl = 6;
|
|
for (int i = 1; i < 9; i++)
|
|
{
|
|
benutzt[i] = false;
|
|
};
|
|
};
|
|
|
|
if (kugelschacht == wahlSchacht)
|
|
{
|
|
gameMode = 2;
|
|
zwangswahl = 6;
|
|
for (int i = 1; i < 9; i++)
|
|
{
|
|
benutzt[i] = false;
|
|
};
|
|
};
|
|
};
|
|
|
|
/*
|
|
if (leerschacht == kugelschacht)
|
|
{
|
|
cout << "Du legst an!" << endl;
|
|
getch();
|
|
cout << "Und drueckst ab, wenn du es wagst ! " << endl;
|
|
getch();
|
|
cout << (char)7 << "BAAAANNNGG" << endl;
|
|
cout << "Du musstest dein Pech mit deinem Leben bezahlen! " << endl;
|
|
cout << "Moechtest du es noch einmal wagen? (j/n)" << endl;
|
|
cin >> i;
|
|
if (i == 'j' || i == 'J')
|
|
{
|
|
goto marke1;
|
|
}
|
|
else _exit(0);
|
|
}
|
|
else if (leerschacht != kugelschacht)
|
|
{
|
|
cout << "Du legst an! " << endl;
|
|
getch();
|
|
cout << "Und drueckst ab, wenn du es wagst !" << endl;
|
|
getch();
|
|
cout << "Clack!" << endl;
|
|
cout << "Du hast glueck gehabt !" << endl;
|
|
zwangswahl -= 1;
|
|
cout << " Du must noch : " << zwangswahl << " mal waehlen!" << endl;
|
|
goto marke2;
|
|
}
|
|
*/
|
|
}
|
|
static void Othello()
|
|
{
|
|
bool Closer = false;
|
|
bool plausiFail = false;
|
|
int backToMode = 0;
|
|
int anzXZuege = 0;
|
|
int anzOZuege = 0;
|
|
int anzXSteine = 0;
|
|
int anzOSteine = 0;
|
|
|
|
string leadPlayer = " ";
|
|
|
|
//Modus 0 = Default
|
|
// 1 = Spiel Neutraler Screen
|
|
// 2 = Spiel Player 1
|
|
// 3 = Spiel Player 2
|
|
// 4 = Player 1 passt
|
|
// 5 = Player 2 passt
|
|
// 6 = Winningscreen
|
|
// 99= Regelscreen
|
|
int gameMode = 0;
|
|
|
|
|
|
|
|
//Initializing des Spielfelds
|
|
string a1 = " ", a2 = " ", a3 = " ", a4 = " ", a5 = " ", a6 = " ", a7 = " ", a8 = " ";
|
|
string b1 = " ", b2 = " ", b3 = " ", b4 = " ", b5 = " ", b6 = " ", b7 = " ", b8 = " ";
|
|
string c1 = " ", c2 = " ", c3 = " ", c4 = " ", c5 = " ", c6 = " ", c7 = " ", c8 = " ";
|
|
string d1 = " ", d2 = " ", d3 = " ", d4 = " ", d5 = " ", d6 = " ", d7 = " ", d8 = " ";
|
|
string e1 = " ", e2 = " ", e3 = " ", e4 = " ", e5 = " ", e6 = " ", e7 = " ", e8 = " ";
|
|
string f1 = " ", f2 = " ", f3 = " ", f4 = " ", f5 = " ", f6 = " ", f7 = " ", f8 = " ";
|
|
string g1 = " ", g2 = " ", g3 = " ", g4 = " ", g5 = " ", g6 = " ", g7 = " ", g8 = " ";
|
|
string h1 = " ", h2 = " ", h3 = " ", h4 = " ", h5 = " ", h6 = " ", h7 = " ", h8 = " ";
|
|
|
|
|
|
String AUSW = " ";
|
|
|
|
while (Closer == false)
|
|
{
|
|
if (gameMode == 99)
|
|
{
|
|
Console.WriteLine("----------------------------------Othello(Regeln)---------------------------");
|
|
Console.WriteLine("- -");
|
|
Console.WriteLine("- -");
|
|
Console.WriteLine("- Siegesbedingung: -");
|
|
Console.WriteLine("- Gewinner des Spiels ist derjenige, der am Ende des Spiels die meisten -");
|
|
Console.WriteLine("- Steine der eigenen Farbe auf dem Feld aufgedeckt hat. -");
|
|
Console.WriteLine("- -");
|
|
Console.WriteLine("- Startaufstellung ist immer vorgegeben und besteht aus jeweils 2 -");
|
|
Console.WriteLine("- Steinen beider Farben, die sich in der Mitte des Feldes(D4/D5/E4/E5) -");
|
|
Console.WriteLine("- diagonal gegenueber stehen. Die Spieler ziehen abwechselnd -");
|
|
Console.WriteLine("- und Schwarz beginnt. -");
|
|
Console.WriteLine("- -");
|
|
Console.WriteLine("- Ein gültiger Zug besteht immer aus dem Setzen eines Steins mit -");
|
|
Console.WriteLine("- eigener Farbe in ein von bereits gelegten Steinen angrenzendes Feld -");
|
|
Console.WriteLine("- und dem Umdrehen von dadurch eingeschlossenen feindlichen Steinen. -");
|
|
Console.WriteLine("- -");
|
|
Console.WriteLine("- Als eingeschlossener Stein gilt ein Stein dann, wenn er -");
|
|
Console.WriteLine("- horizontal, vertikal oder diagonal durch den eben gelegten -");
|
|
Console.WriteLine("- feindlichen Stein und einem weiteren feindlichen Stein in der -");
|
|
Console.WriteLine("- anderen Richtung 'Umzinngelt' ist. Es spielt hierbei keine Rolle -");
|
|
Console.WriteLine("- ob zwischen dem eingeschlossenen Stein und den einschließenden -");
|
|
Console.WriteLine("- Steinen mehrere weitere freundliche Steine liegen. In diesem Fall -");
|
|
Console.WriteLine("- gelten alle freundlichen Steine in dieser eingeschlossenen -");
|
|
Console.WriteLine("- Richtung(Hor/Vert/Diag) als eingeschlossen und werden zur -");
|
|
Console.WriteLine("- anderen Steinfarbe. -");
|
|
Console.WriteLine("- -");
|
|
Console.WriteLine("- Wenn nur Steine gelegt werden können die jedoch nicht zum -");
|
|
Console.WriteLine("- Einschließen von feindlichen Steinen führen würden, gilt dieser -");
|
|
Console.WriteLine("- Zug als Ungültig und muss gepasst werden. -");
|
|
Console.WriteLine("- Können beide Spieler direkt hintereinander nur passen, ist das Spiel -");
|
|
Console.WriteLine("- beendet. -");
|
|
Console.WriteLine("- -");
|
|
Console.WriteLine("- Ist das Spiel beendet werden die Steine gezählt und ausgewertet. -");
|
|
Console.WriteLine("- Bei gleicher Anzahl an Steinen gilt das Spiel als unentschieden. -");
|
|
Console.WriteLine("- -");
|
|
Console.WriteLine("- -");
|
|
Console.WriteLine("----------------------------------------------------------------------------\n\n");
|
|
Console.ReadLine();
|
|
|
|
gameMode = backToMode;
|
|
}
|
|
|
|
if (gameMode == 6)
|
|
{
|
|
Console.Clear();
|
|
Console.WriteLine("----------------------------------------------------------------------------");
|
|
Console.WriteLine("- -");
|
|
Console.WriteLine("- -");
|
|
Console.WriteLine("- Spiel ist beendet. -");
|
|
if (leadPlayer == "X")
|
|
Console.WriteLine("- Spieler 1 gewinnt mit "+ anzOSteine +" Steinen zu "+ anzXSteine +" Steinen! ");
|
|
else
|
|
Console.WriteLine("- Spieler 2 gewinnt mit "+ anzXSteine +" Steinen zu "+ anzOSteine +" Steinen! ");
|
|
Console.WriteLine("- -");
|
|
Console.WriteLine("- -");
|
|
Console.WriteLine("----------------------------------------------------------------------------\n\n");
|
|
Console.ReadLine();
|
|
}
|
|
|
|
|
|
if (gameMode == 0 || gameMode == 2 || gameMode == 3 || gameMode == 4 || gameMode == 5)
|
|
{
|
|
if (gameMode == 2)
|
|
{
|
|
Console.Clear();
|
|
Console.WriteLine("----------------------------------------------------------------------------");
|
|
Console.WriteLine("- -");
|
|
Console.WriteLine("- -");
|
|
Console.WriteLine("- Zug fuer Spieler 1 (O) -");
|
|
Console.WriteLine("- Druecken Sie eine Taste um fortzufahren! -");
|
|
Console.WriteLine("- -");
|
|
Console.WriteLine("- -");
|
|
Console.WriteLine("----------------------------------------------------------------------------\n\n");
|
|
Console.ReadLine();
|
|
}
|
|
|
|
if (gameMode == 3)
|
|
{
|
|
Console.Clear();
|
|
Console.WriteLine("----------------------------------------------------------------------------");
|
|
Console.WriteLine("- -");
|
|
Console.WriteLine("- -");
|
|
Console.WriteLine("- Zug fuer Spieler 2 (X) -");
|
|
Console.WriteLine("- Druecken Sie eine Taste um fortzufahren! -");
|
|
Console.WriteLine("- -");
|
|
Console.WriteLine("- -");
|
|
Console.WriteLine("----------------------------------------------------------------------------\n\n");
|
|
Console.ReadLine();
|
|
}
|
|
|
|
if (gameMode == 4)
|
|
{
|
|
Console.Clear();
|
|
Console.WriteLine("----------------------------------------------------------------------------");
|
|
Console.WriteLine("- -");
|
|
Console.WriteLine("- Spieler 1 muss passen! -");
|
|
Console.WriteLine("- Zug fuer Spieler 2 (O) -");
|
|
Console.WriteLine("- Druecken Sie eine Taste um fortzufahren! -");
|
|
Console.WriteLine("- -");
|
|
Console.WriteLine("- -");
|
|
Console.WriteLine("----------------------------------------------------------------------------\n\n");
|
|
Console.ReadLine();
|
|
}
|
|
|
|
if (gameMode == 5)
|
|
{
|
|
Console.Clear();
|
|
Console.WriteLine("----------------------------------------------------------------------------");
|
|
Console.WriteLine("- -");
|
|
Console.WriteLine("- Spieler 2 muss passen! -");
|
|
Console.WriteLine("- Zug fuer Spieler 1 (O) -");
|
|
Console.WriteLine("- Druecken Sie eine Taste um fortzufahren! -");
|
|
Console.WriteLine("- -");
|
|
Console.WriteLine("- -");
|
|
Console.WriteLine("----------------------------------------------------------------------------\n\n");
|
|
Console.ReadLine();
|
|
}
|
|
|
|
Console.Clear();
|
|
Console.WriteLine("----------------------------------Othello-----------------------------------");
|
|
Console.WriteLine("- (c)2016 A.Degen -");
|
|
Console.WriteLine("- -");
|
|
if (gameMode == 2)
|
|
{
|
|
Console.WriteLine("- Regeln: Auswahl 99 Spieler 1(O) zieht! -");
|
|
Console.WriteLine("- Aktuell fuehrender Spieler : "+ leadPlayer +" -");
|
|
}
|
|
else if (gameMode == 3)
|
|
{
|
|
Console.WriteLine("- Regeln: Auswahl 99 Spieler 2(X) zieht! -");
|
|
Console.WriteLine("- Aktuell fuehrender Spieler : " + leadPlayer + " -");
|
|
}
|
|
else
|
|
Console.WriteLine("- Regeln: Auswahl 99 -");
|
|
Console.WriteLine("- -");
|
|
Console.WriteLine("- A B C D E F G H -");
|
|
Console.WriteLine("- _______________________________________________________________ -");
|
|
Console.WriteLine("- | | | | | | | | | -");
|
|
Console.WriteLine("- 1 | " + a1 + " | " + b1 + " | " + c1 + " | " + d1 + " | " + e1 + " | " + f1 + " | " + g1 + " | " + h1 + " | -");
|
|
Console.WriteLine("- | | | | | | | | | -");
|
|
Console.WriteLine("- |---------------------------------------------------------------| -");
|
|
Console.WriteLine("- | | | | | | | | | -");
|
|
Console.WriteLine("- 2 | " + a2 + " | " + b2 + " | " + c2 + " | " + d2 + " | " + e2 + " | " + f2 + " | " + g2 + " | " + h2 + " | -");
|
|
Console.WriteLine("- | | | | | | | | | -");
|
|
Console.WriteLine("- |---------------------------------------------------------------| -");
|
|
Console.WriteLine("- | | | | | | | | | -");
|
|
Console.WriteLine("- 3 | " + a3 + " | " + b3 + " | " + c3 + " | " + d3 + " | " + e3 + " | " + f3 + " | " + g3 + " | " + h3 + " | -");
|
|
Console.WriteLine("- | | | | | | | | | -");
|
|
Console.WriteLine("- |---------------------------------------------------------------| -");
|
|
Console.WriteLine("- | | | | | | | | | -");
|
|
Console.WriteLine("- 4 | " + a4 + " | " + b4 + " | " + c4 + " | " + d4 + " | " + e4 + " | " + f4 + " | " + g4 + " | " + h4 + " | -");
|
|
Console.WriteLine("- | | | | | | | | | -");
|
|
Console.WriteLine("- |---------------------------------------------------------------| -");
|
|
Console.WriteLine("- | | | | | | | | | -");
|
|
Console.WriteLine("- 5 | " + a5 + " | " + b5 + " | " + c5 + " | " + d5 + " | " + e5 + " | " + f5 + " | " + g5 + " | " + h5 + " | -");
|
|
Console.WriteLine("- | | | | | | | | | -");
|
|
Console.WriteLine("- |---------------------------------------------------------------| -");
|
|
Console.WriteLine("- | | | | | | | | | -");
|
|
Console.WriteLine("- 6 | " + a6 + " | " + b6 + " | " + c6 + " | " + d6 + " | " + e6 + " | " + f6 + " | " + g6 + " | " + h6 + " | -");
|
|
Console.WriteLine("- | | | | | | | | | -");
|
|
Console.WriteLine("- |---------------------------------------------------------------| -");
|
|
Console.WriteLine("- | | | | | | | | | -");
|
|
Console.WriteLine("- 7 | " + a7 + " | " + b7 + " | " + c7 + " | " + d7 + " | " + e7 + " | " + f7 + " | " + g7 + " | " + h7 + " | -");
|
|
Console.WriteLine("- | | | | | | | | | -");
|
|
Console.WriteLine("- |---------------------------------------------------------------| -");
|
|
Console.WriteLine("- | | | | | | | | | -");
|
|
Console.WriteLine("- 8 | " + a8 + " | " + b8 + " | " + c8 + " | " + d8 + " | " + e8 + " | " + f8 + " | " + g8 + " | " + h8 + " | -");
|
|
Console.WriteLine("- | | | | | | | | | -");
|
|
Console.WriteLine("- |_______________________________________________________________| -");
|
|
Console.WriteLine("- -");
|
|
if (gameMode == 0)
|
|
Console.WriteLine("- Auswahl 0 für Spielbeginn! -");
|
|
else if (plausiFail)
|
|
{
|
|
Console.WriteLine("- Kein erlaubter Zug! Bitte waehle einen anderen Zug! -");
|
|
plausiFail = false;
|
|
}
|
|
else
|
|
Console.WriteLine("- -");
|
|
Console.WriteLine("- -");
|
|
Console.WriteLine("----------------------------------------------------------------------------\n\n");
|
|
|
|
|
|
Console.Write("Ihre Auswahl(-1 zum Beenden): ");
|
|
AUSW = Console.ReadLine();
|
|
|
|
//Switch zum Fortschritt des Spiels
|
|
|
|
switch (AUSW)
|
|
{
|
|
case "99": backToMode = gameMode; gameMode = 99; break;
|
|
case "a1":
|
|
case "a2":
|
|
case "a3":
|
|
case "a4":
|
|
case "a5":
|
|
case "a6":
|
|
case "a7":
|
|
case "a8":
|
|
case "b1":
|
|
case "b2":
|
|
case "b3":
|
|
case "b4":
|
|
case "b5":
|
|
case "b6":
|
|
case "b7":
|
|
case "b8":
|
|
case "c1":
|
|
case "c2":
|
|
case "c3":
|
|
case "c4":
|
|
case "c5":
|
|
case "c6":
|
|
case "c7":
|
|
case "c8":
|
|
case "d1":
|
|
case "d2":
|
|
case "d3":
|
|
case "d4":
|
|
case "d5":
|
|
case "d6":
|
|
case "d7":
|
|
case "d8":
|
|
case "e1":
|
|
case "e2":
|
|
case "e3":
|
|
case "e4":
|
|
case "e5":
|
|
case "e6":
|
|
case "e7":
|
|
case "e8":
|
|
case "f1":
|
|
case "f2":
|
|
case "f3":
|
|
case "f4":
|
|
case "f5":
|
|
case "f6":
|
|
case "f7":
|
|
case "f8":
|
|
case "g1":
|
|
case "g2":
|
|
case "g3":
|
|
case "g4":
|
|
case "g5":
|
|
case "g6":
|
|
case "g7":
|
|
case "g8":
|
|
case "h1":
|
|
case "h2":
|
|
case "h3":
|
|
case "h4":
|
|
case "h5":
|
|
case "h6":
|
|
case "h7":
|
|
case "h8":
|
|
|
|
oth_feld_errechnen(ref gameMode, ref AUSW, ref plausiFail, ref anzXZuege, ref anzOZuege, ref leadPlayer, ref anzXSteine, ref anzOSteine,
|
|
ref a1, ref b1, ref c1, ref d1, ref e1, ref f1, ref g1, ref h1,
|
|
ref a2, ref b2, ref c2, ref d2, ref e2, ref f2, ref g2, ref h2,
|
|
ref a3, ref b3, ref c3, ref d3, ref e3, ref f3, ref g3, ref h3,
|
|
ref a4, ref b4, ref c4, ref d4, ref e4, ref f4, ref g4, ref h4,
|
|
ref a5, ref b5, ref c5, ref d5, ref e5, ref f5, ref g5, ref h5,
|
|
ref a6, ref b6, ref c6, ref d6, ref e6, ref f6, ref g6, ref h6,
|
|
ref a7, ref b7, ref c7, ref d7, ref e7, ref f7, ref g7, ref h7,
|
|
ref a8, ref b8, ref c8, ref d8, ref e8, ref f8, ref g8, ref h8); break;
|
|
case "0":
|
|
if (gameMode == 0)
|
|
{
|
|
oth_feld_errechnen(ref gameMode, ref AUSW, ref plausiFail, ref anzXZuege, ref anzOZuege, ref leadPlayer, ref anzXSteine, ref anzOSteine,
|
|
ref a1, ref b1, ref c1, ref d1, ref e1, ref f1, ref g1, ref h1,
|
|
ref a2, ref b2, ref c2, ref d2, ref e2, ref f2, ref g2, ref h2,
|
|
ref a3, ref b3, ref c3, ref d3, ref e3, ref f3, ref g3, ref h3,
|
|
ref a4, ref b4, ref c4, ref d4, ref e4, ref f4, ref g4, ref h4,
|
|
ref a5, ref b5, ref c5, ref d5, ref e5, ref f5, ref g5, ref h5,
|
|
ref a6, ref b6, ref c6, ref d6, ref e6, ref f6, ref g6, ref h6,
|
|
ref a7, ref b7, ref c7, ref d7, ref e7, ref f7, ref g7, ref h7,
|
|
ref a8, ref b8, ref c8, ref d8, ref e8, ref f8, ref g8, ref h8);
|
|
}; break;
|
|
case "-1": Closer = true; break;
|
|
default: Console.WriteLine("Keine gültige Auswahl!"); break;
|
|
};
|
|
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
static void oth_feld_errechnen(ref int gameMode, ref string auswahl, ref bool plausiFail, ref int anzXZuege, ref int anzOZuege, ref string leadPlayer, ref int anzXSteine, ref int anzOSteine,
|
|
ref string a1, ref string b1, ref string c1, ref string d1, ref string e1, ref string f1, ref string g1, ref string h1,
|
|
ref string a2, ref string b2, ref string c2, ref string d2, ref string e2, ref string f2, ref string g2, ref string h2,
|
|
ref string a3, ref string b3, ref string c3, ref string d3, ref string e3, ref string f3, ref string g3, ref string h3,
|
|
ref string a4, ref string b4, ref string c4, ref string d4, ref string e4, ref string f4, ref string g4, ref string h4,
|
|
ref string a5, ref string b5, ref string c5, ref string d5, ref string e5, ref string f5, ref string g5, ref string h5,
|
|
ref string a6, ref string b6, ref string c6, ref string d6, ref string e6, ref string f6, ref string g6, ref string h6,
|
|
ref string a7, ref string b7, ref string c7, ref string d7, ref string e7, ref string f7, ref string g7, ref string h7,
|
|
ref string a8, ref string b8, ref string c8, ref string d8, ref string e8, ref string f8, ref string g8, ref string h8)
|
|
{
|
|
//Variablen fuer überprüfungen
|
|
|
|
bool posOk = false;
|
|
bool wincheck = true;
|
|
|
|
//Conquer-Checkvariablen initialisieren
|
|
bool check_Conquer = false;
|
|
|
|
//Conquer Richtungen mit anzahl für eroberungsmechanik initialisieren
|
|
bool[] conqRichtungen = new bool[8];
|
|
for (int i = 0; i < 8; i++)
|
|
conqRichtungen[i] = false;
|
|
|
|
int[] conqRichtungenAnz = new int[8];
|
|
for (int i = 0; i < 8; i++)
|
|
conqRichtungenAnz[i] = 0;
|
|
|
|
|
|
bool zugEnde = false;
|
|
|
|
// Spieler 1 Logik
|
|
if (gameMode == 2 && !zugEnde)
|
|
{
|
|
//Plausicheck fuer legitime Position (muss umliegend zu gesetzen Steinen sein) und Blockade von anderem Stein
|
|
posOk = false;
|
|
position_check(ref auswahl, ref posOk,
|
|
ref a1, ref b1, ref c1, ref d1, ref e1, ref f1, ref g1, ref h1,
|
|
ref a2, ref b2, ref c2, ref d2, ref e2, ref f2, ref g2, ref h2,
|
|
ref a3, ref b3, ref c3, ref d3, ref e3, ref f3, ref g3, ref h3,
|
|
ref a4, ref b4, ref c4, ref d4, ref e4, ref f4, ref g4, ref h4,
|
|
ref a5, ref b5, ref c5, ref d5, ref e5, ref f5, ref g5, ref h5,
|
|
ref a6, ref b6, ref c6, ref d6, ref e6, ref f6, ref g6, ref h6,
|
|
ref a7, ref b7, ref c7, ref d7, ref e7, ref f7, ref g7, ref h7,
|
|
ref a8, ref b8, ref c8, ref d8, ref e8, ref f8, ref g8, ref h8);
|
|
|
|
//Conquer-check => Conquer moeglich wenn in einer der 9 Richtungen ein oder mehr feindliche und am Ende ein eigener Stein liegt
|
|
// Check-Reihenfolge: Beginn Links im Uhrzeigersinn
|
|
switch (auswahl)
|
|
{
|
|
case "a1":
|
|
case "a2":
|
|
case "a3":
|
|
case "a4":
|
|
case "a5":
|
|
case "a6":
|
|
case "a7":
|
|
case "a8":
|
|
case "b1":
|
|
case "b2":
|
|
case "b3":
|
|
case "b4":
|
|
case "b5":
|
|
case "b6":
|
|
case "b7":
|
|
case "b8":
|
|
case "c1":
|
|
case "c2":
|
|
case "c3":
|
|
case "c4":
|
|
case "c5":
|
|
case "c6":
|
|
case "c7":
|
|
case "c8":
|
|
case "d1":
|
|
case "d2":
|
|
case "d3":
|
|
case "d4":
|
|
case "d5":
|
|
case "d6":
|
|
case "d7":
|
|
case "d8":
|
|
case "e1":
|
|
case "e2":
|
|
case "e3":
|
|
case "e4":
|
|
case "e5":
|
|
case "e6":
|
|
case "e7":
|
|
case "e8":
|
|
case "f1":
|
|
case "f2":
|
|
case "f3":
|
|
case "f4":
|
|
case "f5":
|
|
case "f6":
|
|
case "f7":
|
|
case "f8":
|
|
case "g1":
|
|
case "g2":
|
|
case "g3":
|
|
case "g4":
|
|
case "g5":
|
|
case "g6":
|
|
case "g7":
|
|
case "g8":
|
|
case "h1":
|
|
case "h2":
|
|
case "h3":
|
|
case "h4":
|
|
case "h5":
|
|
case "h6":
|
|
case "h7":
|
|
case "h8":
|
|
|
|
conqCheck(ref auswahl, gameMode, ref conqRichtungenAnz, ref conqRichtungen,
|
|
ref a1, ref b1, ref c1, ref d1, ref e1, ref f1, ref g1, ref h1,
|
|
ref a2, ref b2, ref c2, ref d2, ref e2, ref f2, ref g2, ref h2,
|
|
ref a3, ref b3, ref c3, ref d3, ref e3, ref f3, ref g3, ref h3,
|
|
ref a4, ref b4, ref c4, ref d4, ref e4, ref f4, ref g4, ref h4,
|
|
ref a5, ref b5, ref c5, ref d5, ref e5, ref f5, ref g5, ref h5,
|
|
ref a6, ref b6, ref c6, ref d6, ref e6, ref f6, ref g6, ref h6,
|
|
ref a7, ref b7, ref c7, ref d7, ref e7, ref f7, ref g7, ref h7,
|
|
ref a8, ref b8, ref c8, ref d8, ref e8, ref f8, ref g8, ref h8); break;
|
|
}
|
|
|
|
//überprüfen ob eine Richtung eroberbar ist
|
|
for (int i = 0; i < 8; i++)
|
|
if (conqRichtungen[i] == true)
|
|
check_Conquer = true;
|
|
else if (check_Conquer == true)
|
|
continue;
|
|
else
|
|
check_Conquer = false;
|
|
|
|
// wenn conquer möglich und position legitim dann gewählte position setzen und zugehörige steine erobern
|
|
if (check_Conquer && posOk)
|
|
{
|
|
switch (auswahl)
|
|
{
|
|
case "a1": a1 = "O"; break;
|
|
case "a2": a2 = "O"; break;
|
|
case "a3": a3 = "O"; break;
|
|
case "a4": a4 = "O"; break;
|
|
case "a5": a5 = "O"; break;
|
|
case "a6": a6 = "O"; break;
|
|
case "a7": a7 = "O"; break;
|
|
case "a8": a8 = "O"; break;
|
|
case "b1": b1 = "O"; break;
|
|
case "b2": b2 = "O"; break;
|
|
case "b3": b3 = "O"; break;
|
|
case "b4": b4 = "O"; break;
|
|
case "b5": b5 = "O"; break;
|
|
case "b6": b6 = "O"; break;
|
|
case "b7": b7 = "O"; break;
|
|
case "b8": b8 = "O"; break;
|
|
case "c1": c1 = "O"; break;
|
|
case "c2": c2 = "O"; break;
|
|
case "c3": c3 = "O"; break;
|
|
case "c4": c4 = "O"; break;
|
|
case "c5": c5 = "O"; break;
|
|
case "c6": c6 = "O"; break;
|
|
case "c7": c7 = "O"; break;
|
|
case "c8": c8 = "O"; break;
|
|
case "d1": d1 = "O"; break;
|
|
case "d2": d2 = "O"; break;
|
|
case "d3": d3 = "O"; break;
|
|
case "d4": d4 = "O"; break;
|
|
case "d5": d5 = "O"; break;
|
|
case "d6": d6 = "O"; break;
|
|
case "d7": d7 = "O"; break;
|
|
case "d8": d8 = "O"; break;
|
|
case "e1": e1 = "O"; break;
|
|
case "e2": e2 = "O"; break;
|
|
case "e3": e3 = "O"; break;
|
|
case "e4": e4 = "O"; break;
|
|
case "e5": e5 = "O"; break;
|
|
case "e6": e6 = "O"; break;
|
|
case "e7": e7 = "O"; break;
|
|
case "e8": e8 = "O"; break;
|
|
case "f1": f1 = "O"; break;
|
|
case "f2": f2 = "O"; break;
|
|
case "f3": f3 = "O"; break;
|
|
case "f4": f4 = "O"; break;
|
|
case "f5": f5 = "O"; break;
|
|
case "f6": f6 = "O"; break;
|
|
case "f7": f7 = "O"; break;
|
|
case "f8": f8 = "O"; break;
|
|
case "g1": g1 = "O"; break;
|
|
case "g2": g2 = "O"; break;
|
|
case "g3": g3 = "O"; break;
|
|
case "g4": g4 = "O"; break;
|
|
case "g5": g5 = "O"; break;
|
|
case "g6": g6 = "O"; break;
|
|
case "g7": g7 = "O"; break;
|
|
case "g8": g8 = "O"; break;
|
|
case "h1": h1 = "O"; break;
|
|
case "h2": h2 = "O"; break;
|
|
case "h3": h3 = "O"; break;
|
|
case "h4": h4 = "O"; break;
|
|
case "h5": h5 = "O"; break;
|
|
case "h6": h6 = "O"; break;
|
|
case "h7": h7 = "O"; break;
|
|
case "h8": h8 = "O"; break;
|
|
}
|
|
ConquerSteine(ref auswahl, gameMode, ref conqRichtungenAnz, ref conqRichtungen,
|
|
ref a1, ref b1, ref c1, ref d1, ref e1, ref f1, ref g1, ref h1,
|
|
ref a2, ref b2, ref c2, ref d2, ref e2, ref f2, ref g2, ref h2,
|
|
ref a3, ref b3, ref c3, ref d3, ref e3, ref f3, ref g3, ref h3,
|
|
ref a4, ref b4, ref c4, ref d4, ref e4, ref f4, ref g4, ref h4,
|
|
ref a5, ref b5, ref c5, ref d5, ref e5, ref f5, ref g5, ref h5,
|
|
ref a6, ref b6, ref c6, ref d6, ref e6, ref f6, ref g6, ref h6,
|
|
ref a7, ref b7, ref c7, ref d7, ref e7, ref f7, ref g7, ref h7,
|
|
ref a8, ref b8, ref c8, ref d8, ref e8, ref f8, ref g8, ref h8);
|
|
|
|
|
|
//Überprüfung ob noch Züge möglich sind -> wenn nein spiel zuende
|
|
winningCheck(ref anzXZuege, ref anzOZuege, ref wincheck, ref leadPlayer,
|
|
ref a1, ref b1, ref c1, ref d1, ref e1, ref f1, ref g1, ref h1,
|
|
ref a2, ref b2, ref c2, ref d2, ref e2, ref f2, ref g2, ref h2,
|
|
ref a3, ref b3, ref c3, ref d3, ref e3, ref f3, ref g3, ref h3,
|
|
ref a4, ref b4, ref c4, ref d4, ref e4, ref f4, ref g4, ref h4,
|
|
ref a5, ref b5, ref c5, ref d5, ref e5, ref f5, ref g5, ref h5,
|
|
ref a6, ref b6, ref c6, ref d6, ref e6, ref f6, ref g6, ref h6,
|
|
ref a7, ref b7, ref c7, ref d7, ref e7, ref f7, ref g7, ref h7,
|
|
ref a8, ref b8, ref c8, ref d8, ref e8, ref f8, ref g8, ref h8);
|
|
//zugende
|
|
zugEnde = true;
|
|
if (wincheck == true)
|
|
{
|
|
gameMode = 6;
|
|
//zählen der Steine für Gesammt ergebnis
|
|
countField(ref anzXSteine, ref anzOSteine,
|
|
ref a1, ref b1, ref c1, ref d1, ref e1, ref f1, ref g1, ref h1,
|
|
ref a2, ref b2, ref c2, ref d2, ref e2, ref f2, ref g2, ref h2,
|
|
ref a3, ref b3, ref c3, ref d3, ref e3, ref f3, ref g3, ref h3,
|
|
ref a4, ref b4, ref c4, ref d4, ref e4, ref f4, ref g4, ref h4,
|
|
ref a5, ref b5, ref c5, ref d5, ref e5, ref f5, ref g5, ref h5,
|
|
ref a6, ref b6, ref c6, ref d6, ref e6, ref f6, ref g6, ref h6,
|
|
ref a7, ref b7, ref c7, ref d7, ref e7, ref f7, ref g7, ref h7,
|
|
ref a8, ref b8, ref c8, ref d8, ref e8, ref f8, ref g8, ref h8);
|
|
}
|
|
else
|
|
gameMode = 3;
|
|
}
|
|
else
|
|
{
|
|
// wenn keine eroberung möglich dann neuwahl der position
|
|
zugEnde = true;
|
|
plausiFail = true;
|
|
gameMode = 2;
|
|
}
|
|
}
|
|
|
|
// Spieler 2 Logik
|
|
if (gameMode == 3 && !zugEnde)
|
|
{
|
|
//Plausicheck fuer die Auswahl
|
|
posOk = false;
|
|
position_check(ref auswahl, ref posOk,
|
|
ref a1, ref b1, ref c1, ref d1, ref e1, ref f1, ref g1, ref h1,
|
|
ref a2, ref b2, ref c2, ref d2, ref e2, ref f2, ref g2, ref h2,
|
|
ref a3, ref b3, ref c3, ref d3, ref e3, ref f3, ref g3, ref h3,
|
|
ref a4, ref b4, ref c4, ref d4, ref e4, ref f4, ref g4, ref h4,
|
|
ref a5, ref b5, ref c5, ref d5, ref e5, ref f5, ref g5, ref h5,
|
|
ref a6, ref b6, ref c6, ref d6, ref e6, ref f6, ref g6, ref h6,
|
|
ref a7, ref b7, ref c7, ref d7, ref e7, ref f7, ref g7, ref h7,
|
|
ref a8, ref b8, ref c8, ref d8, ref e8, ref f8, ref g8, ref h8);
|
|
|
|
//Conquer-check => Conquer moeglich wenn in einer der 9 Richtungen ein oder mehr feindliche und am Ende ein eigener Stein liegt
|
|
// Check-Reihenfolge: Beginn Links im Uhrzeigersinn
|
|
switch (auswahl)
|
|
{
|
|
case "a1":
|
|
case "a2":
|
|
case "a3":
|
|
case "a4":
|
|
case "a5":
|
|
case "a6":
|
|
case "a7":
|
|
case "a8":
|
|
case "b1":
|
|
case "b2":
|
|
case "b3":
|
|
case "b4":
|
|
case "b5":
|
|
case "b6":
|
|
case "b7":
|
|
case "b8":
|
|
case "c1":
|
|
case "c2":
|
|
case "c3":
|
|
case "c4":
|
|
case "c5":
|
|
case "c6":
|
|
case "c7":
|
|
case "c8":
|
|
case "d1":
|
|
case "d2":
|
|
case "d3":
|
|
case "d4":
|
|
case "d5":
|
|
case "d6":
|
|
case "d7":
|
|
case "d8":
|
|
case "e1":
|
|
case "e2":
|
|
case "e3":
|
|
case "e4":
|
|
case "e5":
|
|
case "e6":
|
|
case "e7":
|
|
case "e8":
|
|
case "f1":
|
|
case "f2":
|
|
case "f3":
|
|
case "f4":
|
|
case "f5":
|
|
case "f6":
|
|
case "f7":
|
|
case "f8":
|
|
case "g1":
|
|
case "g2":
|
|
case "g3":
|
|
case "g4":
|
|
case "g5":
|
|
case "g6":
|
|
case "g7":
|
|
case "g8":
|
|
case "h1":
|
|
case "h2":
|
|
case "h3":
|
|
case "h4":
|
|
case "h5":
|
|
case "h6":
|
|
case "h7":
|
|
case "h8":
|
|
conqCheck(ref auswahl, gameMode, ref conqRichtungenAnz, ref conqRichtungen,
|
|
ref a1, ref b1, ref c1, ref d1, ref e1, ref f1, ref g1, ref h1,
|
|
ref a2, ref b2, ref c2, ref d2, ref e2, ref f2, ref g2, ref h2,
|
|
ref a3, ref b3, ref c3, ref d3, ref e3, ref f3, ref g3, ref h3,
|
|
ref a4, ref b4, ref c4, ref d4, ref e4, ref f4, ref g4, ref h4,
|
|
ref a5, ref b5, ref c5, ref d5, ref e5, ref f5, ref g5, ref h5,
|
|
ref a6, ref b6, ref c6, ref d6, ref e6, ref f6, ref g6, ref h6,
|
|
ref a7, ref b7, ref c7, ref d7, ref e7, ref f7, ref g7, ref h7,
|
|
ref a8, ref b8, ref c8, ref d8, ref e8, ref f8, ref g8, ref h8);
|
|
break;
|
|
|
|
}
|
|
|
|
//überprüfen ob eine Richtung eroberbar ist
|
|
for (int i = 0; i < 8; i++)
|
|
if (conqRichtungen[i] == true)
|
|
check_Conquer = true;
|
|
else if (check_Conquer == true)
|
|
continue;
|
|
else
|
|
check_Conquer = false;
|
|
|
|
if (check_Conquer && posOk)
|
|
{
|
|
switch (auswahl)
|
|
{
|
|
case "a1": a1 = "X"; break;
|
|
case "a2": a2 = "X"; break;
|
|
case "a3": a3 = "X"; break;
|
|
case "a4": a4 = "X"; break;
|
|
case "a5": a5 = "X"; break;
|
|
case "a6": a6 = "X"; break;
|
|
case "a7": a7 = "X"; break;
|
|
case "a8": a8 = "X"; break;
|
|
case "b1": b1 = "X"; break;
|
|
case "b2": b2 = "X"; break;
|
|
case "b3": b3 = "X"; break;
|
|
case "b4": b4 = "X"; break;
|
|
case "b5": b5 = "X"; break;
|
|
case "b6": b6 = "X"; break;
|
|
case "b7": b7 = "X"; break;
|
|
case "b8": b8 = "X"; break;
|
|
case "c1": c1 = "X"; break;
|
|
case "c2": c2 = "X"; break;
|
|
case "c3": c3 = "X"; break;
|
|
case "c4": c4 = "X"; break;
|
|
case "c5": c5 = "X"; break;
|
|
case "c6": c6 = "X"; break;
|
|
case "c7": c7 = "X"; break;
|
|
case "c8": c8 = "X"; break;
|
|
case "d1": d1 = "X"; break;
|
|
case "d2": d2 = "X"; break;
|
|
case "d3": d3 = "X"; break;
|
|
case "d4": d4 = "X"; break;
|
|
case "d5": d5 = "X"; break;
|
|
case "d6": d6 = "X"; break;
|
|
case "d7": d7 = "X"; break;
|
|
case "d8": d8 = "X"; break;
|
|
case "e1": e1 = "X"; break;
|
|
case "e2": e2 = "X"; break;
|
|
case "e3": e3 = "X"; break;
|
|
case "e4": e4 = "X"; break;
|
|
case "e5": e5 = "X"; break;
|
|
case "e6": e6 = "X"; break;
|
|
case "e7": e7 = "X"; break;
|
|
case "e8": e8 = "X"; break;
|
|
case "f1": f1 = "X"; break;
|
|
case "f2": f2 = "X"; break;
|
|
case "f3": f3 = "X"; break;
|
|
case "f4": f4 = "X"; break;
|
|
case "f5": f5 = "X"; break;
|
|
case "f6": f6 = "X"; break;
|
|
case "f7": f7 = "X"; break;
|
|
case "f8": f8 = "X"; break;
|
|
case "g1": g1 = "X"; break;
|
|
case "g2": g2 = "X"; break;
|
|
case "g3": g3 = "X"; break;
|
|
case "g4": g4 = "X"; break;
|
|
case "g5": g5 = "X"; break;
|
|
case "g6": g6 = "X"; break;
|
|
case "g7": g7 = "X"; break;
|
|
case "g8": g8 = "X"; break;
|
|
case "h1": h1 = "X"; break;
|
|
case "h2": h2 = "X"; break;
|
|
case "h3": h3 = "X"; break;
|
|
case "h4": h4 = "X"; break;
|
|
case "h5": h5 = "X"; break;
|
|
case "h6": h6 = "X"; break;
|
|
case "h7": h7 = "X"; break;
|
|
case "h8": h8 = "X"; break;
|
|
}
|
|
ConquerSteine(ref auswahl, gameMode, ref conqRichtungenAnz, ref conqRichtungen,
|
|
ref a1, ref b1, ref c1, ref d1, ref e1, ref f1, ref g1, ref h1,
|
|
ref a2, ref b2, ref c2, ref d2, ref e2, ref f2, ref g2, ref h2,
|
|
ref a3, ref b3, ref c3, ref d3, ref e3, ref f3, ref g3, ref h3,
|
|
ref a4, ref b4, ref c4, ref d4, ref e4, ref f4, ref g4, ref h4,
|
|
ref a5, ref b5, ref c5, ref d5, ref e5, ref f5, ref g5, ref h5,
|
|
ref a6, ref b6, ref c6, ref d6, ref e6, ref f6, ref g6, ref h6,
|
|
ref a7, ref b7, ref c7, ref d7, ref e7, ref f7, ref g7, ref h7,
|
|
ref a8, ref b8, ref c8, ref d8, ref e8, ref f8, ref g8, ref h8);
|
|
|
|
//zugende
|
|
|
|
//hier logik für überprüfung der endsiegbedingung einbauen
|
|
|
|
zugEnde = true;
|
|
gameMode = 2;
|
|
}
|
|
else
|
|
{
|
|
// wenn keine eroberung möglich dann neuwahl der position
|
|
zugEnde = true;
|
|
plausiFail = true;
|
|
gameMode = 3;
|
|
}
|
|
}
|
|
|
|
// start aufstellung
|
|
if (gameMode == 0 && !zugEnde)
|
|
{
|
|
d4 = "X";
|
|
d5 = "O";
|
|
e4 = "O";
|
|
e5 = "X";
|
|
gameMode = 2;
|
|
}
|
|
|
|
|
|
}
|
|
|
|
static void position_check(ref string auswahl, ref bool posOk,
|
|
ref string a1, ref string b1, ref string c1, ref string d1, ref string e1, ref string f1, ref string g1, ref string h1,
|
|
ref string a2, ref string b2, ref string c2, ref string d2, ref string e2, ref string f2, ref string g2, ref string h2,
|
|
ref string a3, ref string b3, ref string c3, ref string d3, ref string e3, ref string f3, ref string g3, ref string h3,
|
|
ref string a4, ref string b4, ref string c4, ref string d4, ref string e4, ref string f4, ref string g4, ref string h4,
|
|
ref string a5, ref string b5, ref string c5, ref string d5, ref string e5, ref string f5, ref string g5, ref string h5,
|
|
ref string a6, ref string b6, ref string c6, ref string d6, ref string e6, ref string f6, ref string g6, ref string h6,
|
|
ref string a7, ref string b7, ref string c7, ref string d7, ref string e7, ref string f7, ref string g7, ref string h7,
|
|
ref string a8, ref string b8, ref string c8, ref string d8, ref string e8, ref string f8, ref string g8, ref string h8)
|
|
{
|
|
bool check_rechts = false;
|
|
bool check_obenR = false;
|
|
bool check_untenR = false;
|
|
bool check_links = false;
|
|
bool check_untenL = false;
|
|
bool check_obenL = false;
|
|
bool check_unten = false;
|
|
bool check_oben = false;
|
|
bool blockiert = false;
|
|
//initalisieren
|
|
posOk = false;
|
|
|
|
switch (auswahl)
|
|
{
|
|
//Positionsmuster Links beginnend im Uhrzeigersinn
|
|
|
|
//1.Reihe
|
|
case "a1":
|
|
if (b1 != " ") check_rechts = true;
|
|
if (b2 != " ") check_untenR = true;
|
|
if (a2 != " ") check_unten = true;
|
|
if (a1 != " ") blockiert = true;
|
|
break;
|
|
case "b1":
|
|
if (a1 != " ") check_links = true;
|
|
if (c1 != " ") check_rechts = true;
|
|
if (c2 != " ") check_untenR = true;
|
|
if (b2 != " ") check_unten = true;
|
|
if (a2 != " ") check_untenL = true;
|
|
if (b1 != " ") blockiert = true;
|
|
break;
|
|
case "c1":
|
|
if (b1 != " ") check_links = true;
|
|
if (d1 != " ") check_rechts = true;
|
|
if (d2 != " ") check_untenR = true;
|
|
if (c2 != " ") check_unten = true;
|
|
if (b2 != " ") check_untenL = true;
|
|
if (c1 != " ") blockiert = true;
|
|
break;
|
|
case "d1":
|
|
if (c1 != " ") check_links = true;
|
|
if (e1 != " ") check_rechts = true;
|
|
if (e2 != " ") check_untenR = true;
|
|
if (d2 != " ") check_unten = true;
|
|
if (c2 != " ") check_untenL = true;
|
|
if (d1 != " ") blockiert = true;
|
|
break;
|
|
case "e1":
|
|
if (d1 != " ") check_links = true;
|
|
if (f1 != " ") check_rechts = true;
|
|
if (f2 != " ") check_untenR = true;
|
|
if (e2 != " ") check_unten = true;
|
|
if (d2 != " ") check_untenL = true;
|
|
if (e1 != " ") blockiert = true;
|
|
break;
|
|
case "f1":
|
|
if (e1 != " ") check_links = true;
|
|
if (g1 != " ") check_rechts = true;
|
|
if (g2 != " ") check_untenR = true;
|
|
if (f2 != " ") check_unten = true;
|
|
if (e2 != " ") check_untenL = true;
|
|
if (f1 != " ") blockiert = true;
|
|
break;
|
|
case "g1":
|
|
if (f1 != " ") check_links = true;
|
|
if (h1 != " ") check_rechts = true;
|
|
if (h2 != " ") check_untenR = true;
|
|
if (g2 != " ") check_unten = true;
|
|
if (f2 != " ") check_untenL = true;
|
|
if (g1 != " ") blockiert = true;
|
|
break;
|
|
case "h1":
|
|
if (g1 != " ") check_links = true;
|
|
if (h2 != " ") check_unten = true;
|
|
if (g2 != " ") check_untenL = true;
|
|
if (h1 != " ") blockiert = true;
|
|
break;
|
|
|
|
// 2. Reihe
|
|
|
|
case "a2":
|
|
if (a1 != " ") check_oben = true;
|
|
if (b1 != " ") check_obenR = true;
|
|
if (b2 != " ") check_rechts = true;
|
|
if (b3 != " ") check_untenR = true;
|
|
if (a3 != " ") check_unten = true;
|
|
if (a2 != " ") blockiert = true;
|
|
break;
|
|
case "b2":
|
|
if (a2 != " ") check_links = true;
|
|
if (a1 != " ") check_obenL = true;
|
|
if (b1 != " ") check_oben = true;
|
|
if (c1 != " ") check_obenR = true;
|
|
if (c2 != " ") check_rechts = true;
|
|
if (c3 != " ") check_untenR = true;
|
|
if (b3 != " ") check_unten = true;
|
|
if (a3 != " ") check_untenL = true;
|
|
if (b2 != " ") blockiert = true;
|
|
break;
|
|
case "c2":
|
|
if (b2 != " ") check_links = true;
|
|
if (b1 != " ") check_obenL = true;
|
|
if (c1 != " ") check_oben = true;
|
|
if (d1 != " ") check_obenR = true;
|
|
if (d2 != " ") check_rechts = true;
|
|
if (d3 != " ") check_untenR = true;
|
|
if (c3 != " ") check_unten = true;
|
|
if (b3 != " ") check_untenL = true;
|
|
if (c2 != " ") blockiert = true;
|
|
break;
|
|
case "d2":
|
|
if (c2 != " ") check_links = true;
|
|
if (c1 != " ") check_obenL = true;
|
|
if (d1 != " ") check_oben = true;
|
|
if (e1 != " ") check_obenR = true;
|
|
if (e2 != " ") check_rechts = true;
|
|
if (e3 != " ") check_untenR = true;
|
|
if (d3 != " ") check_unten = true;
|
|
if (c3 != " ") check_untenL = true;
|
|
if (d2 != " ") blockiert = true;
|
|
break;
|
|
case "e2":
|
|
if (d2 != " ") check_links = true;
|
|
if (d1 != " ") check_obenL = true;
|
|
if (e1 != " ") check_oben = true;
|
|
if (f1 != " ") check_obenR = true;
|
|
if (f2 != " ") check_rechts = true;
|
|
if (f3 != " ") check_untenR = true;
|
|
if (e3 != " ") check_unten = true;
|
|
if (d3 != " ") check_untenL = true;
|
|
if (e2 != " ") blockiert = true;
|
|
break;
|
|
case "f2":
|
|
if (d2 != " ") check_links = true;
|
|
if (e1 != " ") check_obenL = true;
|
|
if (f1 != " ") check_oben = true;
|
|
if (g1 != " ") check_obenR = true;
|
|
if (g2 != " ") check_rechts = true;
|
|
if (g3 != " ") check_untenR = true;
|
|
if (f3 != " ") check_unten = true;
|
|
if (e3 != " ") check_untenL = true;
|
|
if (f2 != " ") blockiert = true;
|
|
break;
|
|
case "g2":
|
|
if (e2 != " ") check_links = true;
|
|
if (f1 != " ") check_obenL = true;
|
|
if (g1 != " ") check_oben = true;
|
|
if (h1 != " ") check_obenR = true;
|
|
if (h2 != " ") check_rechts = true;
|
|
if (h3 != " ") check_untenR = true;
|
|
if (g3 != " ") check_unten = true;
|
|
if (f3 != " ") check_untenL = true;
|
|
if (g2 != " ") blockiert = true;
|
|
break;
|
|
case "h2":
|
|
if (g2 != " ") check_links = true;
|
|
if (g1 != " ") check_obenL = true;
|
|
if (h1 != " ") check_oben = true;
|
|
if (h3 != " ") check_unten = true;
|
|
if (g3 != " ") check_untenL = true;
|
|
if (h2 != " ") blockiert = true;
|
|
break;
|
|
|
|
//Reihe 3
|
|
|
|
case "a3":
|
|
if (a2 != " ") check_oben = true;
|
|
if (b2 != " ") check_obenR = true;
|
|
if (b3 != " ") check_rechts = true;
|
|
if (b4 != " ") check_untenR = true;
|
|
if (a4 != " ") check_unten = true;
|
|
if (a3 != " ") blockiert = true;
|
|
break;
|
|
case "b3":
|
|
if (a3 != " ") check_links = true;
|
|
if (a2 != " ") check_obenL = true;
|
|
if (b2 != " ") check_oben = true;
|
|
if (c2 != " ") check_obenR = true;
|
|
if (c3 != " ") check_rechts = true;
|
|
if (c4 != " ") check_untenR = true;
|
|
if (b4 != " ") check_unten = true;
|
|
if (a4 != " ") check_untenL = true;
|
|
if (b3 != " ") blockiert = true;
|
|
break;
|
|
case "c3":
|
|
if (b3 != " ") check_links = true;
|
|
if (b2 != " ") check_obenL = true;
|
|
if (c2 != " ") check_oben = true;
|
|
if (d2 != " ") check_obenR = true;
|
|
if (d3 != " ") check_rechts = true;
|
|
if (d4 != " ") check_untenR = true;
|
|
if (c4 != " ") check_unten = true;
|
|
if (b4 != " ") check_untenL = true;
|
|
if (c3 != " ") blockiert = true;
|
|
break;
|
|
case "d3":
|
|
if (c3 != " ") check_links = true;
|
|
if (c2 != " ") check_obenL = true;
|
|
if (d2 != " ") check_oben = true;
|
|
if (e2 != " ") check_obenR = true;
|
|
if (e3 != " ") check_rechts = true;
|
|
if (e4 != " ") check_untenR = true;
|
|
if (d4 != " ") check_unten = true;
|
|
if (c4 != " ") check_untenL = true;
|
|
if (d3 != " ") blockiert = true;
|
|
break;
|
|
case "e3":
|
|
if (d3 != " ") check_links = true;
|
|
if (d2 != " ") check_obenL = true;
|
|
if (e2 != " ") check_oben = true;
|
|
if (f2 != " ") check_obenR = true;
|
|
if (f3 != " ") check_rechts = true;
|
|
if (f4 != " ") check_untenR = true;
|
|
if (e4 != " ") check_unten = true;
|
|
if (d4 != " ") check_untenL = true;
|
|
if (e3 != " ") blockiert = true;
|
|
break;
|
|
case "f3":
|
|
if (d3 != " ") check_links = true;
|
|
if (e2 != " ") check_obenL = true;
|
|
if (f2 != " ") check_oben = true;
|
|
if (g2 != " ") check_obenR = true;
|
|
if (g3 != " ") check_rechts = true;
|
|
if (g4 != " ") check_untenR = true;
|
|
if (f4 != " ") check_unten = true;
|
|
if (e4 != " ") check_untenL = true;
|
|
if (f3 != " ") blockiert = true;
|
|
break;
|
|
case "g3":
|
|
if (e3 != " ") check_links = true;
|
|
if (f2 != " ") check_obenL = true;
|
|
if (g2 != " ") check_oben = true;
|
|
if (h2 != " ") check_obenR = true;
|
|
if (h3 != " ") check_rechts = true;
|
|
if (h4 != " ") check_untenR = true;
|
|
if (g4 != " ") check_unten = true;
|
|
if (f4 != " ") check_untenL = true;
|
|
if (g3 != " ") blockiert = true;
|
|
break;
|
|
case "h3":
|
|
if (g3 != " ") check_links = true;
|
|
if (g2 != " ") check_obenL = true;
|
|
if (h2 != " ") check_oben = true;
|
|
if (h4 != " ") check_unten = true;
|
|
if (g4 != " ") check_untenL = true;
|
|
if (h3 != " ") blockiert = true;
|
|
break;
|
|
|
|
//Reihe 4
|
|
|
|
case "a4":
|
|
if (a3 != " ") check_oben = true;
|
|
if (b3 != " ") check_obenR = true;
|
|
if (b4 != " ") check_rechts = true;
|
|
if (b5 != " ") check_untenR = true;
|
|
if (a5 != " ") check_unten = true;
|
|
if (a4 != " ") blockiert = true;
|
|
break;
|
|
case "b4":
|
|
if (a4 != " ") check_links = true;
|
|
if (a3 != " ") check_obenL = true;
|
|
if (b3 != " ") check_oben = true;
|
|
if (c3 != " ") check_obenR = true;
|
|
if (c4 != " ") check_rechts = true;
|
|
if (c5 != " ") check_untenR = true;
|
|
if (b5 != " ") check_unten = true;
|
|
if (a5 != " ") check_untenL = true;
|
|
if (b4 != " ") blockiert = true;
|
|
break;
|
|
case "c4":
|
|
if (b4 != " ") check_links = true;
|
|
if (b3 != " ") check_obenL = true;
|
|
if (c3 != " ") check_oben = true;
|
|
if (d3 != " ") check_obenR = true;
|
|
if (d4 != " ") check_rechts = true;
|
|
if (d5 != " ") check_untenR = true;
|
|
if (c5 != " ") check_unten = true;
|
|
if (b5 != " ") check_untenL = true;
|
|
if (c4 != " ") blockiert = true;
|
|
break;
|
|
case "d4":
|
|
if (c4 != " ") check_links = true;
|
|
if (c3 != " ") check_obenL = true;
|
|
if (d3 != " ") check_oben = true;
|
|
if (e3 != " ") check_obenR = true;
|
|
if (e4 != " ") check_rechts = true;
|
|
if (e5 != " ") check_untenR = true;
|
|
if (d5 != " ") check_unten = true;
|
|
if (c5 != " ") check_untenL = true;
|
|
if (d4 != " ") blockiert = true;
|
|
break;
|
|
case "e4":
|
|
if (d4 != " ") check_links = true;
|
|
if (d3 != " ") check_obenL = true;
|
|
if (e3 != " ") check_oben = true;
|
|
if (f3 != " ") check_obenR = true;
|
|
if (f4 != " ") check_rechts = true;
|
|
if (f5 != " ") check_untenR = true;
|
|
if (e5 != " ") check_unten = true;
|
|
if (d5 != " ") check_untenL = true;
|
|
if (e4 != " ") blockiert = true;
|
|
break;
|
|
case "f4":
|
|
if (d4 != " ") check_links = true;
|
|
if (e3 != " ") check_obenL = true;
|
|
if (f3 != " ") check_oben = true;
|
|
if (g3 != " ") check_obenR = true;
|
|
if (g4 != " ") check_rechts = true;
|
|
if (g5 != " ") check_untenR = true;
|
|
if (f5 != " ") check_unten = true;
|
|
if (e5 != " ") check_untenL = true;
|
|
if (f4 != " ") blockiert = true;
|
|
break;
|
|
case "g4":
|
|
if (e4 != " ") check_links = true;
|
|
if (f3 != " ") check_obenL = true;
|
|
if (g3 != " ") check_oben = true;
|
|
if (h3 != " ") check_obenR = true;
|
|
if (h4 != " ") check_rechts = true;
|
|
if (h5 != " ") check_untenR = true;
|
|
if (g5 != " ") check_unten = true;
|
|
if (f5 != " ") check_untenL = true;
|
|
if (g4 != " ") blockiert = true;
|
|
break;
|
|
case "h4":
|
|
if (g4 != " ") check_links = true;
|
|
if (g3 != " ") check_obenL = true;
|
|
if (h3 != " ") check_oben = true;
|
|
if (h5 != " ") check_unten = true;
|
|
if (g5 != " ") check_untenL = true;
|
|
if (h4 != " ") blockiert = true;
|
|
break;
|
|
|
|
//Reihe 5
|
|
|
|
case "a5":
|
|
if (a4 != " ") check_oben = true;
|
|
if (b5 != " ") check_obenR = true;
|
|
if (b5 != " ") check_rechts = true;
|
|
if (b6 != " ") check_untenR = true;
|
|
if (a6 != " ") check_unten = true;
|
|
if (a5 != " ") blockiert = true;
|
|
break;
|
|
case "b5":
|
|
if (a5 != " ") check_links = true;
|
|
if (a4 != " ") check_obenL = true;
|
|
if (b4 != " ") check_oben = true;
|
|
if (c4 != " ") check_obenR = true;
|
|
if (c5 != " ") check_rechts = true;
|
|
if (c6 != " ") check_untenR = true;
|
|
if (b6 != " ") check_unten = true;
|
|
if (a6 != " ") check_untenL = true;
|
|
if (b5 != " ") blockiert = true;
|
|
break;
|
|
case "c5":
|
|
if (b5 != " ") check_links = true;
|
|
if (b4 != " ") check_obenL = true;
|
|
if (c4 != " ") check_oben = true;
|
|
if (d4 != " ") check_obenR = true;
|
|
if (d5 != " ") check_rechts = true;
|
|
if (d6 != " ") check_untenR = true;
|
|
if (c6 != " ") check_unten = true;
|
|
if (b6 != " ") check_untenL = true;
|
|
if (c5 != " ") blockiert = true;
|
|
break;
|
|
case "d5":
|
|
if (c5 != " ") check_links = true;
|
|
if (c4 != " ") check_obenL = true;
|
|
if (d4 != " ") check_oben = true;
|
|
if (e4 != " ") check_obenR = true;
|
|
if (e5 != " ") check_rechts = true;
|
|
if (e6 != " ") check_untenR = true;
|
|
if (d6 != " ") check_unten = true;
|
|
if (c6 != " ") check_untenL = true;
|
|
if (d5 != " ") blockiert = true;
|
|
break;
|
|
case "e5":
|
|
if (d5 != " ") check_links = true;
|
|
if (d4 != " ") check_obenL = true;
|
|
if (e4 != " ") check_oben = true;
|
|
if (f4 != " ") check_obenR = true;
|
|
if (f5 != " ") check_rechts = true;
|
|
if (f6 != " ") check_untenR = true;
|
|
if (e6 != " ") check_unten = true;
|
|
if (d6 != " ") check_untenL = true;
|
|
if (e5 != " ") blockiert = true;
|
|
break;
|
|
case "f5":
|
|
if (d5 != " ") check_links = true;
|
|
if (e4 != " ") check_obenL = true;
|
|
if (f4 != " ") check_oben = true;
|
|
if (g4 != " ") check_obenR = true;
|
|
if (g5 != " ") check_rechts = true;
|
|
if (g6 != " ") check_untenR = true;
|
|
if (f6 != " ") check_unten = true;
|
|
if (e6 != " ") check_untenL = true;
|
|
if (f5 != " ") blockiert = true;
|
|
break;
|
|
case "g5":
|
|
if (e5 != " ") check_links = true;
|
|
if (f4 != " ") check_obenL = true;
|
|
if (g4 != " ") check_oben = true;
|
|
if (h4 != " ") check_obenR = true;
|
|
if (h5 != " ") check_rechts = true;
|
|
if (h6 != " ") check_untenR = true;
|
|
if (g6 != " ") check_unten = true;
|
|
if (f6 != " ") check_untenL = true;
|
|
if (g5 != " ") blockiert = true;
|
|
break;
|
|
case "h5":
|
|
if (g5 != " ") check_links = true;
|
|
if (g4 != " ") check_obenL = true;
|
|
if (h4 != " ") check_oben = true;
|
|
if (h6 != " ") check_unten = true;
|
|
if (g6 != " ") check_untenL = true;
|
|
if (h5 != " ") blockiert = true;
|
|
break;
|
|
|
|
//Reihe 6
|
|
|
|
case "a6":
|
|
if (a5 != " ") check_oben = true;
|
|
if (b6 != " ") check_obenR = true;
|
|
if (b6 != " ") check_rechts = true;
|
|
if (b7 != " ") check_untenR = true;
|
|
if (a7 != " ") check_unten = true;
|
|
if (a6 != " ") blockiert = true;
|
|
break;
|
|
case "b6":
|
|
if (a6 != " ") check_links = true;
|
|
if (a5 != " ") check_obenL = true;
|
|
if (b5 != " ") check_oben = true;
|
|
if (c5 != " ") check_obenR = true;
|
|
if (c6 != " ") check_rechts = true;
|
|
if (c7 != " ") check_untenR = true;
|
|
if (b7 != " ") check_unten = true;
|
|
if (a7 != " ") check_untenL = true;
|
|
if (b6 != " ") blockiert = true;
|
|
break;
|
|
case "c6":
|
|
if (b6 != " ") check_links = true;
|
|
if (b5 != " ") check_obenL = true;
|
|
if (c5 != " ") check_oben = true;
|
|
if (d5 != " ") check_obenR = true;
|
|
if (d6 != " ") check_rechts = true;
|
|
if (d7 != " ") check_untenR = true;
|
|
if (c7 != " ") check_unten = true;
|
|
if (b7 != " ") check_untenL = true;
|
|
if (c6 != " ") blockiert = true;
|
|
break;
|
|
case "d6":
|
|
if (c6 != " ") check_links = true;
|
|
if (c5 != " ") check_obenL = true;
|
|
if (d5 != " ") check_oben = true;
|
|
if (e5 != " ") check_obenR = true;
|
|
if (e6 != " ") check_rechts = true;
|
|
if (e7 != " ") check_untenR = true;
|
|
if (d7 != " ") check_unten = true;
|
|
if (c7 != " ") check_untenL = true;
|
|
if (d6 != " ") blockiert = true;
|
|
break;
|
|
case "e6":
|
|
if (d6 != " ") check_links = true;
|
|
if (d5 != " ") check_obenL = true;
|
|
if (e5 != " ") check_oben = true;
|
|
if (f5 != " ") check_obenR = true;
|
|
if (f6 != " ") check_rechts = true;
|
|
if (f7 != " ") check_untenR = true;
|
|
if (e7 != " ") check_unten = true;
|
|
if (d7 != " ") check_untenL = true;
|
|
if (e6 != " ") blockiert = true;
|
|
break;
|
|
case "f6":
|
|
if (d6 != " ") check_links = true;
|
|
if (e5 != " ") check_obenL = true;
|
|
if (f5 != " ") check_oben = true;
|
|
if (g5 != " ") check_obenR = true;
|
|
if (g6 != " ") check_rechts = true;
|
|
if (g7 != " ") check_untenR = true;
|
|
if (f7 != " ") check_unten = true;
|
|
if (e7 != " ") check_untenL = true;
|
|
if (f6 != " ") blockiert = true;
|
|
break;
|
|
case "g6":
|
|
if (e6 != " ") check_links = true;
|
|
if (f5 != " ") check_obenL = true;
|
|
if (g5 != " ") check_oben = true;
|
|
if (h5 != " ") check_obenR = true;
|
|
if (h6 != " ") check_rechts = true;
|
|
if (h7 != " ") check_untenR = true;
|
|
if (g7 != " ") check_unten = true;
|
|
if (f7 != " ") check_untenL = true;
|
|
if (g6 != " ") blockiert = true;
|
|
break;
|
|
case "h6":
|
|
if (g6 != " ") check_links = true;
|
|
if (g5 != " ") check_obenL = true;
|
|
if (h5 != " ") check_oben = true;
|
|
if (h7 != " ") check_unten = true;
|
|
if (g7 != " ") check_untenL = true;
|
|
if (h6 != " ") blockiert = true;
|
|
break;
|
|
|
|
//Reihe 7
|
|
|
|
case "a7":
|
|
if (a6 != " ") check_oben = true;
|
|
if (b7 != " ") check_obenR = true;
|
|
if (b7 != " ") check_rechts = true;
|
|
if (b8 != " ") check_untenR = true;
|
|
if (a8 != " ") check_unten = true;
|
|
if (a7 != " ") blockiert = true;
|
|
break;
|
|
case "b7":
|
|
if (a7 != " ") check_links = true;
|
|
if (a6 != " ") check_obenL = true;
|
|
if (b6 != " ") check_oben = true;
|
|
if (c6 != " ") check_obenR = true;
|
|
if (c7 != " ") check_rechts = true;
|
|
if (c8 != " ") check_untenR = true;
|
|
if (b8 != " ") check_unten = true;
|
|
if (a8 != " ") check_untenL = true;
|
|
if (b7 != " ") blockiert = true;
|
|
break;
|
|
case "c7":
|
|
if (b7 != " ") check_links = true;
|
|
if (b6 != " ") check_obenL = true;
|
|
if (c6 != " ") check_oben = true;
|
|
if (d6 != " ") check_obenR = true;
|
|
if (d7 != " ") check_rechts = true;
|
|
if (d8 != " ") check_untenR = true;
|
|
if (c8 != " ") check_unten = true;
|
|
if (b8 != " ") check_untenL = true;
|
|
if (c7 != " ") blockiert = true;
|
|
break;
|
|
case "d7":
|
|
if (c7 != " ") check_links = true;
|
|
if (c6 != " ") check_obenL = true;
|
|
if (d6 != " ") check_oben = true;
|
|
if (e6 != " ") check_obenR = true;
|
|
if (e7 != " ") check_rechts = true;
|
|
if (e8 != " ") check_untenR = true;
|
|
if (d8 != " ") check_unten = true;
|
|
if (c8 != " ") check_untenL = true;
|
|
if (d7 != " ") blockiert = true;
|
|
break;
|
|
case "e7":
|
|
if (d7 != " ") check_links = true;
|
|
if (d6 != " ") check_obenL = true;
|
|
if (e6 != " ") check_oben = true;
|
|
if (f6 != " ") check_obenR = true;
|
|
if (f7 != " ") check_rechts = true;
|
|
if (f8 != " ") check_untenR = true;
|
|
if (e8 != " ") check_unten = true;
|
|
if (d8 != " ") check_untenL = true;
|
|
if (e7 != " ") blockiert = true;
|
|
break;
|
|
case "f7":
|
|
if (d7 != " ") check_links = true;
|
|
if (e6 != " ") check_obenL = true;
|
|
if (f6 != " ") check_oben = true;
|
|
if (g6 != " ") check_obenR = true;
|
|
if (g7 != " ") check_rechts = true;
|
|
if (g8 != " ") check_untenR = true;
|
|
if (f8 != " ") check_unten = true;
|
|
if (e8 != " ") check_untenL = true;
|
|
if (f7 != " ") blockiert = true;
|
|
break;
|
|
case "g7":
|
|
if (e7 != " ") check_links = true;
|
|
if (f6 != " ") check_obenL = true;
|
|
if (g6 != " ") check_oben = true;
|
|
if (h6 != " ") check_obenR = true;
|
|
if (h7 != " ") check_rechts = true;
|
|
if (h8 != " ") check_untenR = true;
|
|
if (g8 != " ") check_unten = true;
|
|
if (f8 != " ") check_untenL = true;
|
|
if (g7 != " ") blockiert = true;
|
|
break;
|
|
case "h7":
|
|
if (g7 != " ") check_links = true;
|
|
if (g6 != " ") check_obenL = true;
|
|
if (h6 != " ") check_oben = true;
|
|
if (h8 != " ") check_unten = true;
|
|
if (g8 != " ") check_untenL = true;
|
|
if (h7 != " ") blockiert = true;
|
|
break;
|
|
|
|
//Reihe 8
|
|
|
|
case "a8":
|
|
if (a6 != " ") check_oben = true;
|
|
if (b7 != " ") check_obenR = true;
|
|
if (b7 != " ") check_rechts = true;
|
|
if (a8 != " ") blockiert = true;
|
|
break;
|
|
case "b8":
|
|
if (a7 != " ") check_links = true;
|
|
if (a6 != " ") check_obenL = true;
|
|
if (b6 != " ") check_oben = true;
|
|
if (c6 != " ") check_obenR = true;
|
|
if (c7 != " ") check_rechts = true;
|
|
if (b8 != " ") blockiert = true;
|
|
break;
|
|
case "c8":
|
|
if (b7 != " ") check_links = true;
|
|
if (b6 != " ") check_obenL = true;
|
|
if (c6 != " ") check_oben = true;
|
|
if (d6 != " ") check_obenR = true;
|
|
if (d7 != " ") check_rechts = true;
|
|
if (c8 != " ") blockiert = true;
|
|
break;
|
|
case "d8":
|
|
if (c7 != " ") check_links = true;
|
|
if (c6 != " ") check_obenL = true;
|
|
if (d6 != " ") check_oben = true;
|
|
if (e6 != " ") check_obenR = true;
|
|
if (e7 != " ") check_rechts = true;
|
|
if (d8 != " ") blockiert = true;
|
|
break;
|
|
case "e8":
|
|
if (d7 != " ") check_links = true;
|
|
if (d6 != " ") check_obenL = true;
|
|
if (e6 != " ") check_oben = true;
|
|
if (f6 != " ") check_obenR = true;
|
|
if (f7 != " ") check_rechts = true;
|
|
if (e8 != " ") blockiert = true;
|
|
break;
|
|
case "f8":
|
|
if (d7 != " ") check_links = true;
|
|
if (e6 != " ") check_obenL = true;
|
|
if (f6 != " ") check_oben = true;
|
|
if (g6 != " ") check_obenR = true;
|
|
if (g7 != " ") check_rechts = true;
|
|
if (f8 != " ") blockiert = true;
|
|
break;
|
|
case "g8":
|
|
if (e7 != " ") check_links = true;
|
|
if (f6 != " ") check_obenL = true;
|
|
if (g6 != " ") check_oben = true;
|
|
if (h6 != " ") check_obenR = true;
|
|
if (h7 != " ") check_rechts = true;
|
|
if (g8 != " ") blockiert = true;
|
|
break;
|
|
case "h8":
|
|
if (g7 != " ") check_links = true;
|
|
if (g6 != " ") check_obenL = true;
|
|
if (h6 != " ") check_oben = true;
|
|
if (h8 != " ") blockiert = true;
|
|
break;
|
|
}
|
|
|
|
if ((check_links || check_obenL || check_oben || check_obenR || check_rechts || check_untenR || check_unten || check_untenL) && !blockiert)
|
|
{
|
|
posOk = true;
|
|
}
|
|
|
|
}
|
|
|
|
static void conqCheck(ref string auswahl, int gameMode, ref int[] conqRichtungenAnz, ref bool[] conqRichtungen,
|
|
ref string a1, ref string b1, ref string c1, ref string d1, ref string e1, ref string f1, ref string g1, ref string h1,
|
|
ref string a2, ref string b2, ref string c2, ref string d2, ref string e2, ref string f2, ref string g2, ref string h2,
|
|
ref string a3, ref string b3, ref string c3, ref string d3, ref string e3, ref string f3, ref string g3, ref string h3,
|
|
ref string a4, ref string b4, ref string c4, ref string d4, ref string e4, ref string f4, ref string g4, ref string h4,
|
|
ref string a5, ref string b5, ref string c5, ref string d5, ref string e5, ref string f5, ref string g5, ref string h5,
|
|
ref string a6, ref string b6, ref string c6, ref string d6, ref string e6, ref string f6, ref string g6, ref string h6,
|
|
ref string a7, ref string b7, ref string c7, ref string d7, ref string e7, ref string f7, ref string g7, ref string h7,
|
|
ref string a8, ref string b8, ref string c8, ref string d8, ref string e8, ref string f8, ref string g8, ref string h8)
|
|
{
|
|
//schleifenbedingung
|
|
bool checkComplete = false;
|
|
bool conquerPosible = false;
|
|
|
|
//zu checkende position
|
|
string curCheckPos = auswahl;
|
|
|
|
//temp variablen für check position
|
|
char checkSpalte;
|
|
int checkReihe;
|
|
|
|
//variablen für eroberungskriterien
|
|
string playerCheck;
|
|
string enemyCheck;
|
|
|
|
//richtungsvariablen
|
|
/* 0= Links
|
|
* 1= LOben
|
|
* 2= Oben
|
|
* 3= ROben
|
|
* 4= Rechts
|
|
* 5= RUnten
|
|
* 6= Unten
|
|
* 7= LUnten */
|
|
int richtung = 0;
|
|
|
|
//initialisieren der eroberbaren Richtungen
|
|
for (int i = 0; i < 8; i++)
|
|
{
|
|
conqRichtungen[i] = false;
|
|
conqRichtungenAnz[i] = 0;
|
|
|
|
}
|
|
|
|
//zählvariable für anzahl von zu erobernden steinen
|
|
int anz_Conq = 0;
|
|
|
|
//variable für beenden des Checks einer Richtung
|
|
bool checkFertig = false;
|
|
|
|
// Schleife zum Check für mögliche Eroberung und in welche richtungen eroberung möglich ist
|
|
while (checkComplete == false)
|
|
{
|
|
//übernahme der aktuellen koordinaten in die überprüfungsmechanik
|
|
checkSpalte = Convert.ToChar(curCheckPos.Substring(0, 1));
|
|
checkReihe = Convert.ToInt32(curCheckPos.Substring(1, 1));
|
|
|
|
switch (richtung)
|
|
{
|
|
case 0:// verändern der positionskordinate auf dem feld nach links d.h. erste koordinate -1
|
|
checkSpalte = (char)(checkSpalte - 1);
|
|
if (checkSpalte < 'a')
|
|
checkFertig = true;
|
|
else
|
|
curCheckPos = checkSpalte + Convert.ToString(checkReihe); break;
|
|
case 1:// verändern der positionskordinate auf dem feld nach oben links d.h. erste koordinate -1 zweite koordinate(zahl)-1
|
|
checkSpalte = (char)(checkSpalte - 1);
|
|
checkReihe = checkReihe - 1;
|
|
if (checkSpalte < 'a' || checkReihe < 1)
|
|
checkFertig = true;
|
|
else
|
|
curCheckPos = checkSpalte + Convert.ToString(checkReihe); break;
|
|
case 2:// verändern der positionskordinate auf dem feld nach oben d.h. zweite koordinate(zahl) veringert sich um 1
|
|
checkReihe = checkReihe - 1;
|
|
if (checkReihe < 1)
|
|
checkFertig = true;
|
|
else
|
|
curCheckPos = checkSpalte + Convert.ToString(checkReihe); break;
|
|
case 3:// verändern der positionskordinate auf dem feld nach oben rechts d.h. erste koordinate +1 zweite koordinate(zahl)-1
|
|
checkSpalte = (char)(checkSpalte + 1);
|
|
checkReihe = checkReihe - 1;
|
|
if (checkSpalte > 'h' || checkReihe < 1)
|
|
checkFertig = true;
|
|
else
|
|
curCheckPos = checkSpalte + Convert.ToString(checkReihe); break;
|
|
case 4:// verändern der positionskordinate auf dem feld nach rechts d.h. erste koordinate +1
|
|
checkSpalte = (char)(checkSpalte + 1);
|
|
if (checkSpalte > 'h')
|
|
checkFertig = true;
|
|
else
|
|
curCheckPos = checkSpalte + Convert.ToString(checkReihe); break;
|
|
case 5:// verändern der positionskordinate auf dem feld nach unten rechts d.h. erste koordinate +1 zweite koordinate(zahl)+1
|
|
checkSpalte = (char)(checkSpalte + 1);
|
|
checkReihe = checkReihe + 1;
|
|
if (checkSpalte > 'h' || checkReihe > 8)
|
|
checkFertig = true;
|
|
else
|
|
curCheckPos = checkSpalte + Convert.ToString(checkReihe); break;
|
|
case 6:// verändern der positionskordinate auf dem feld nach unten d.h. zweite koordinate(zahl) erhöht sich um 1
|
|
checkReihe = checkReihe + 1;
|
|
if (checkReihe > 8)
|
|
checkFertig = true;
|
|
else
|
|
curCheckPos = checkSpalte + Convert.ToString(checkReihe); break;
|
|
case 7:// verändern der positionskordinate auf dem feld nach unten links d.h. erste koordinate -1 zweite koordinate(zahl)+1
|
|
|
|
checkSpalte = (char)(checkSpalte - 1);
|
|
checkReihe = checkReihe + 1;
|
|
if (checkSpalte > 'h' || checkReihe < 1)
|
|
checkFertig = true;
|
|
else
|
|
curCheckPos = checkSpalte + Convert.ToString(checkReihe); break;
|
|
}
|
|
|
|
// Eroberungskriterien für Spieler 1 (O) und Spieler 2 (X)
|
|
if (gameMode == 2)
|
|
{
|
|
playerCheck = "O";
|
|
enemyCheck = "X";
|
|
|
|
}
|
|
else
|
|
{
|
|
playerCheck = "X";
|
|
enemyCheck = "O";
|
|
}
|
|
|
|
//check des feldinhaltes auf eroberungskriterien
|
|
if (!checkFertig)
|
|
{
|
|
switch (curCheckPos)
|
|
{
|
|
case "a1":
|
|
if (a1 == enemyCheck) anz_Conq++;
|
|
if (a1 == playerCheck && anz_Conq > 0) conquerPosible = true;
|
|
if (a1 == " ") checkFertig = true;
|
|
|
|
break;
|
|
case "a2":
|
|
if (a2 == enemyCheck) anz_Conq++;
|
|
if (a2 == playerCheck && anz_Conq > 0) conquerPosible = true;
|
|
if (a2 == " ") checkFertig = true; break;
|
|
case "a3":
|
|
if (a3 == enemyCheck) anz_Conq++;
|
|
if (a3 == playerCheck && anz_Conq > 0) conquerPosible = true;
|
|
if (a3 == " ") checkFertig = true; break;
|
|
case "a4":
|
|
if (a4 == enemyCheck) anz_Conq++;
|
|
if (a4 == playerCheck && anz_Conq > 0) conquerPosible = true;
|
|
if (a4 == " ") checkFertig = true; break;
|
|
case "a5":
|
|
if (a5 == enemyCheck) anz_Conq++;
|
|
if (a5 == playerCheck && anz_Conq > 0) conquerPosible = true;
|
|
if (a5 == " ") checkFertig = true; break;
|
|
case "a6":
|
|
if (a6 == enemyCheck) anz_Conq++;
|
|
if (a6 == playerCheck && anz_Conq > 0) conquerPosible = true;
|
|
if (a6 == " ") checkFertig = true; break;
|
|
case "a7":
|
|
if (a7 == enemyCheck) anz_Conq++;
|
|
if (a7 == playerCheck && anz_Conq > 0) conquerPosible = true;
|
|
if (a7 == " ") checkFertig = true; break;
|
|
case "a8":
|
|
if (a8 == enemyCheck) anz_Conq++;
|
|
if (a8 == playerCheck && anz_Conq > 0) conquerPosible = true;
|
|
if (a8 == " ") checkFertig = true; break;
|
|
case "b1":
|
|
if (b1 == enemyCheck) anz_Conq++;
|
|
if (b1 == playerCheck && anz_Conq > 0) conquerPosible = true;
|
|
if (b1 == " ") checkFertig = true; break;
|
|
case "b2":
|
|
if (b2 == enemyCheck) anz_Conq++;
|
|
if (b2 == playerCheck && anz_Conq > 0) conquerPosible = true;
|
|
if (b2 == " ") checkFertig = true; break;
|
|
case "b3":
|
|
if (b3 == enemyCheck) anz_Conq++;
|
|
if (b3 == playerCheck && anz_Conq > 0) conquerPosible = true;
|
|
if (b3 == " ") checkFertig = true; break;
|
|
case "b4":
|
|
if (b4 == enemyCheck) anz_Conq++;
|
|
if (b4 == playerCheck && anz_Conq > 0) conquerPosible = true;
|
|
if (b4 == " ") checkFertig = true; break;
|
|
case "b5":
|
|
if (b5 == enemyCheck) anz_Conq++;
|
|
if (b5 == playerCheck && anz_Conq > 0) conquerPosible = true;
|
|
if (b5 == " ") checkFertig = true; break;
|
|
case "b6":
|
|
if (b6 == enemyCheck) anz_Conq++;
|
|
if (b6 == playerCheck && anz_Conq > 0) conquerPosible = true;
|
|
if (b6 == " ") checkFertig = true; break;
|
|
case "b7":
|
|
if (b7 == enemyCheck) anz_Conq++;
|
|
if (b7 == playerCheck && anz_Conq > 0) conquerPosible = true;
|
|
if (b7 == " ") checkFertig = true; break;
|
|
case "b8":
|
|
if (b8 == enemyCheck) anz_Conq++;
|
|
if (b8 == playerCheck && anz_Conq > 0) conquerPosible = true;
|
|
if (b8 == " ") checkFertig = true; break;
|
|
case "c1":
|
|
if (c1 == enemyCheck) anz_Conq++;
|
|
if (c1 == playerCheck && anz_Conq > 0) conquerPosible = true;
|
|
if (c1 == " ") checkFertig = true; break;
|
|
case "c2":
|
|
if (c2 == enemyCheck) anz_Conq++;
|
|
if (c2 == playerCheck && anz_Conq > 0) conquerPosible = true;
|
|
if (c2 == " ") checkFertig = true; break;
|
|
case "c3":
|
|
if (c3 == enemyCheck) anz_Conq++;
|
|
if (c3 == playerCheck && anz_Conq > 0) conquerPosible = true;
|
|
if (c3 == " ") checkFertig = true; break;
|
|
case "c4":
|
|
if (c4 == enemyCheck) anz_Conq++;
|
|
if (c4 == playerCheck && anz_Conq > 0) conquerPosible = true;
|
|
if (c4 == " ") checkFertig = true; break;
|
|
case "c5":
|
|
if (c5 == enemyCheck) anz_Conq++;
|
|
if (c5 == playerCheck && anz_Conq > 0) conquerPosible = true;
|
|
if (c5 == " ") checkFertig = true; break;
|
|
case "c6":
|
|
if (c6 == enemyCheck) anz_Conq++;
|
|
if (c6 == playerCheck && anz_Conq > 0) conquerPosible = true;
|
|
if (c6 == " ") checkFertig = true; break;
|
|
case "c7":
|
|
if (c7 == enemyCheck) anz_Conq++;
|
|
if (c7 == playerCheck && anz_Conq > 0) conquerPosible = true;
|
|
if (c7 == " ") checkFertig = true; break;
|
|
case "c8":
|
|
if (c8 == enemyCheck) anz_Conq++;
|
|
if (c8 == playerCheck && anz_Conq > 0) conquerPosible = true;
|
|
if (c8 == " ") checkFertig = true; break;
|
|
case "d1":
|
|
if (d1 == enemyCheck) anz_Conq++;
|
|
if (d1 == playerCheck && anz_Conq > 0) conquerPosible = true;
|
|
if (d1 == " ") checkFertig = true; break;
|
|
case "d2":
|
|
if (d2 == enemyCheck) anz_Conq++;
|
|
if (d2 == playerCheck && anz_Conq > 0) conquerPosible = true;
|
|
if (d2 == " ") checkFertig = true; break;
|
|
case "d3":
|
|
if (d3 == enemyCheck) anz_Conq++;
|
|
if (d3 == playerCheck && anz_Conq > 0) conquerPosible = true;
|
|
if (d3 == " ") checkFertig = true; break;
|
|
case "d4":
|
|
if (d4 == enemyCheck) anz_Conq++;
|
|
if (d4 == playerCheck && anz_Conq > 0) conquerPosible = true;
|
|
if (d4 == " ") checkFertig = true; break;
|
|
case "d5":
|
|
if (d5 == enemyCheck) anz_Conq++;
|
|
if (d5 == playerCheck && anz_Conq > 0) conquerPosible = true;
|
|
if (d5 == " ") checkFertig = true; break;
|
|
case "d6":
|
|
if (d6 == enemyCheck) anz_Conq++;
|
|
if (d6 == playerCheck && anz_Conq > 0) conquerPosible = true;
|
|
if (d6 == " ") checkFertig = true; break;
|
|
case "d7":
|
|
if (d7 == enemyCheck) anz_Conq++;
|
|
if (d7 == playerCheck && anz_Conq > 0) conquerPosible = true;
|
|
if (d7 == " ") checkFertig = true; break;
|
|
case "d8":
|
|
if (d8 == enemyCheck) anz_Conq++;
|
|
if (d8 == playerCheck && anz_Conq > 0) conquerPosible = true;
|
|
if (d8 == " ") checkFertig = true; break;
|
|
case "e1":
|
|
if (e1 == enemyCheck) anz_Conq++;
|
|
if (e1 == playerCheck && anz_Conq > 0) conquerPosible = true;
|
|
if (e1 == " ") checkFertig = true; break;
|
|
case "e2":
|
|
if (e2 == enemyCheck) anz_Conq++;
|
|
if (e2 == playerCheck && anz_Conq > 0) conquerPosible = true;
|
|
if (e2 == " ") checkFertig = true; break;
|
|
case "e3":
|
|
if (e3 == enemyCheck) anz_Conq++;
|
|
if (e3 == playerCheck && anz_Conq > 0) conquerPosible = true;
|
|
if (e3 == " ") checkFertig = true; break;
|
|
case "e4":
|
|
if (e4 == enemyCheck) anz_Conq++;
|
|
if (e4 == playerCheck && anz_Conq > 0) conquerPosible = true;
|
|
if (e4 == " ") checkFertig = true; break;
|
|
case "e5":
|
|
if (e5 == enemyCheck) anz_Conq++;
|
|
if (e5 == playerCheck && anz_Conq > 0) conquerPosible = true;
|
|
if (e5 == " ") checkFertig = true; break;
|
|
case "e6":
|
|
if (e6 == enemyCheck) anz_Conq++;
|
|
if (e6 == playerCheck && anz_Conq > 0) conquerPosible = true;
|
|
if (e6 == " ") checkFertig = true; break;
|
|
case "e7":
|
|
if (e7 == enemyCheck) anz_Conq++;
|
|
if (e7 == playerCheck && anz_Conq > 0) conquerPosible = true;
|
|
if (e7 == " ") checkFertig = true; break;
|
|
case "e8":
|
|
if (e8 == enemyCheck) anz_Conq++;
|
|
if (e8 == playerCheck && anz_Conq > 0) conquerPosible = true;
|
|
if (e8 == " ") checkFertig = true; break;
|
|
case "f1":
|
|
if (f1 == enemyCheck) anz_Conq++;
|
|
if (f1 == playerCheck && anz_Conq > 0) conquerPosible = true;
|
|
if (f1 == " ") checkFertig = true; break;
|
|
case "f2":
|
|
if (f2 == enemyCheck) anz_Conq++;
|
|
if (f2 == playerCheck && anz_Conq > 0) conquerPosible = true;
|
|
if (f2 == " ") checkFertig = true; break;
|
|
case "f3":
|
|
if (f3 == enemyCheck) anz_Conq++;
|
|
if (f3 == playerCheck && anz_Conq > 0) conquerPosible = true;
|
|
if (f3 == " ") checkFertig = true; break;
|
|
case "f4":
|
|
if (f4 == enemyCheck) anz_Conq++;
|
|
if (f4 == playerCheck && anz_Conq > 0) conquerPosible = true;
|
|
if (f4 == " ") checkFertig = true; break;
|
|
case "f5":
|
|
if (f5 == enemyCheck) anz_Conq++;
|
|
if (f5 == playerCheck && anz_Conq > 0) conquerPosible = true;
|
|
if (f5 == " ") checkFertig = true; break;
|
|
case "f6":
|
|
if (f6 == enemyCheck) anz_Conq++;
|
|
if (f6 == playerCheck && anz_Conq > 0) conquerPosible = true;
|
|
if (f6 == " ") checkFertig = true; break;
|
|
case "f7":
|
|
if (f7 == enemyCheck) anz_Conq++;
|
|
if (f7 == playerCheck && anz_Conq > 0) conquerPosible = true;
|
|
if (f7 == " ") checkFertig = true; break;
|
|
case "f8":
|
|
if (f8 == enemyCheck) anz_Conq++;
|
|
if (f8 == playerCheck && anz_Conq > 0) conquerPosible = true;
|
|
if (f8 == " ") checkFertig = true; break;
|
|
case "g1":
|
|
if (g1 == enemyCheck) anz_Conq++;
|
|
if (g1 == playerCheck && anz_Conq > 0) conquerPosible = true;
|
|
if (g1 == " ") checkFertig = true; break;
|
|
case "g2":
|
|
if (g2 == enemyCheck) anz_Conq++;
|
|
if (g2 == playerCheck && anz_Conq > 0) conquerPosible = true;
|
|
if (g2 == " ") checkFertig = true; break;
|
|
case "g3":
|
|
if (g3 == enemyCheck) anz_Conq++;
|
|
if (g3 == playerCheck && anz_Conq > 0) conquerPosible = true;
|
|
if (g3 == " ") checkFertig = true; break;
|
|
case "g4":
|
|
if (g4 == enemyCheck) anz_Conq++;
|
|
if (g4 == playerCheck && anz_Conq > 0) conquerPosible = true;
|
|
if (g4 == " ") checkFertig = true; break;
|
|
case "g5":
|
|
if (g5 == enemyCheck) anz_Conq++;
|
|
if (g5 == playerCheck && anz_Conq > 0) conquerPosible = true;
|
|
if (g5 == " ") checkFertig = true; break;
|
|
case "g6":
|
|
if (g6 == enemyCheck) anz_Conq++;
|
|
if (g6 == playerCheck && anz_Conq > 0) conquerPosible = true;
|
|
if (g6 == " ") checkFertig = true; break;
|
|
case "g7":
|
|
if (g7 == enemyCheck) anz_Conq++;
|
|
if (g7 == playerCheck && anz_Conq > 0) conquerPosible = true;
|
|
if (g7 == " ") checkFertig = true; break;
|
|
case "g8":
|
|
if (g8 == enemyCheck) anz_Conq++;
|
|
if (g8 == playerCheck && anz_Conq > 0) conquerPosible = true;
|
|
if (g8 == " ") checkFertig = true; break;
|
|
case "h1":
|
|
if (h1 == enemyCheck) anz_Conq++;
|
|
if (h1 == playerCheck && anz_Conq > 0) conquerPosible = true;
|
|
if (h1 == " ") checkFertig = true; break;
|
|
case "h2":
|
|
if (h2 == enemyCheck) anz_Conq++;
|
|
if (h2 == playerCheck && anz_Conq > 0) conquerPosible = true;
|
|
if (h2 == " ") checkFertig = true; break;
|
|
case "h3":
|
|
if (h3 == enemyCheck) anz_Conq++;
|
|
if (h3 == playerCheck && anz_Conq > 0) conquerPosible = true;
|
|
if (h3 == " ") checkFertig = true; break;
|
|
case "h4":
|
|
if (h4 == enemyCheck) anz_Conq++;
|
|
if (h4 == playerCheck && anz_Conq > 0) conquerPosible = true;
|
|
if (h4 == " ") checkFertig = true; break;
|
|
case "h5":
|
|
if (h5 == enemyCheck) anz_Conq++;
|
|
if (h5 == playerCheck && anz_Conq > 0) conquerPosible = true;
|
|
if (h5 == " ") checkFertig = true; break;
|
|
case "h6":
|
|
if (h6 == enemyCheck) anz_Conq++;
|
|
if (h6 == playerCheck && anz_Conq > 0) conquerPosible = true;
|
|
if (h6 == " ") checkFertig = true; break;
|
|
case "h7":
|
|
if (h7 == enemyCheck) anz_Conq++;
|
|
if (h7 == playerCheck && anz_Conq > 0) conquerPosible = true;
|
|
if (h7 == " ") checkFertig = true; break;
|
|
case "h8":
|
|
if (h8 == playerCheck) anz_Conq++;
|
|
if (h8 == enemyCheck && anz_Conq > 0) conquerPosible = true;
|
|
if (h8 == " ") checkFertig = true; break;
|
|
|
|
}
|
|
}
|
|
|
|
if (richtung == 7 && (conquerPosible ||checkFertig))
|
|
{
|
|
if (conquerPosible)
|
|
{
|
|
conqRichtungen[richtung] = true;
|
|
conqRichtungenAnz[richtung] = anz_Conq;
|
|
}
|
|
checkComplete = true;
|
|
}
|
|
else if (checkFertig)
|
|
{
|
|
if (conquerPosible)
|
|
{
|
|
conqRichtungen[richtung] = true;
|
|
conqRichtungenAnz[richtung] = anz_Conq;
|
|
conquerPosible = false;
|
|
}
|
|
richtung++;
|
|
anz_Conq = 0;
|
|
checkFertig = false;
|
|
curCheckPos = auswahl;
|
|
}
|
|
|
|
|
|
|
|
}
|
|
}
|
|
|
|
static void ConquerSteine(ref string auswahl, int gameMode, ref int[] conqRichtungenAnz, ref bool[] conqRichtungen,
|
|
ref string a1, ref string b1, ref string c1, ref string d1, ref string e1, ref string f1, ref string g1, ref string h1,
|
|
ref string a2, ref string b2, ref string c2, ref string d2, ref string e2, ref string f2, ref string g2, ref string h2,
|
|
ref string a3, ref string b3, ref string c3, ref string d3, ref string e3, ref string f3, ref string g3, ref string h3,
|
|
ref string a4, ref string b4, ref string c4, ref string d4, ref string e4, ref string f4, ref string g4, ref string h4,
|
|
ref string a5, ref string b5, ref string c5, ref string d5, ref string e5, ref string f5, ref string g5, ref string h5,
|
|
ref string a6, ref string b6, ref string c6, ref string d6, ref string e6, ref string f6, ref string g6, ref string h6,
|
|
ref string a7, ref string b7, ref string c7, ref string d7, ref string e7, ref string f7, ref string g7, ref string h7,
|
|
ref string a8, ref string b8, ref string c8, ref string d8, ref string e8, ref string f8, ref string g8, ref string h8)
|
|
{
|
|
//zu checkende position
|
|
string curCheckPos = auswahl;
|
|
|
|
//temp variablen für conq position
|
|
char conqSpalte;
|
|
int conqReihe;
|
|
|
|
|
|
//Schleifendurchlauf für alle zu erobernden Richtungen
|
|
for (int richtungsZaehler = 0; richtungsZaehler < 8; richtungsZaehler++)
|
|
{
|
|
curCheckPos = auswahl;
|
|
//schleifendurchlauf für die Anzahl der Eroberungsschritte für die jeweilige Richtung
|
|
for (; conqRichtungenAnz[richtungsZaehler] > 0; conqRichtungenAnz[richtungsZaehler]--)
|
|
{
|
|
|
|
//übernahme der aktuellen koordinaten in die überprüfungsmechanik
|
|
conqSpalte = Convert.ToChar(curCheckPos.Substring(0, 1));
|
|
conqReihe = Convert.ToInt32(curCheckPos.Substring(1, 1));
|
|
|
|
switch (richtungsZaehler)
|
|
{
|
|
case 0:// verändern der positionskordinate auf dem feld nach links d.h. erste koordinate -1
|
|
conqSpalte = (char)(conqSpalte - 1);
|
|
curCheckPos = conqSpalte + Convert.ToString(conqReihe); break;
|
|
case 1:// verändern der positionskordinate auf dem feld nach oben links d.h. erste koordinate -1 zweite koordinate(zahl)-1
|
|
conqSpalte = (char)(conqSpalte - 1);
|
|
conqReihe = conqReihe - 1;
|
|
curCheckPos = conqSpalte + Convert.ToString(conqReihe); break;
|
|
case 2:// verändern der positionskordinate auf dem feld nach oben d.h. zweite koordinate(zahl) veringert sich um 1
|
|
conqReihe = conqReihe - 1;
|
|
curCheckPos = conqSpalte + Convert.ToString(conqReihe); break;
|
|
case 3:// verändern der positionskordinate auf dem feld nach oben rechts d.h. erste koordinate +1 zweite koordinate(zahl)-1
|
|
conqSpalte = (char)(conqSpalte + 1);
|
|
conqReihe = conqReihe - 1;
|
|
curCheckPos = conqSpalte + Convert.ToString(conqReihe); break;
|
|
case 4:// verändern der positionskordinate auf dem feld nach rechts d.h. erste koordinate +1
|
|
conqSpalte = (char)(conqSpalte + 1);
|
|
curCheckPos = conqSpalte + Convert.ToString(conqReihe); break;
|
|
case 5:// verändern der positionskordinate auf dem feld nach unten rechts d.h. erste koordinate +1 zweite koordinate(zahl)+1
|
|
conqSpalte = (char)(conqSpalte + 1);
|
|
conqReihe = conqReihe + 1;
|
|
curCheckPos = conqSpalte + Convert.ToString(conqReihe); break;
|
|
case 6:// verändern der positionskordinate auf dem feld nach unten d.h. zweite koordinate(zahl) erhöht sich um 1
|
|
conqReihe = conqReihe + 1;
|
|
curCheckPos = conqSpalte + Convert.ToString(conqReihe); break;
|
|
case 7:// verändern der positionskordinate auf dem feld nach unten links d.h. erste koordinate -1 zweite koordinate(zahl)+1
|
|
conqSpalte = (char)(conqSpalte - 1);
|
|
conqReihe = conqReihe + 1;
|
|
curCheckPos = conqSpalte + Convert.ToString(conqReihe); break;
|
|
}
|
|
|
|
if (gameMode == 3)
|
|
{
|
|
|
|
switch (curCheckPos)
|
|
{
|
|
case "a1": a1 = "X"; break;
|
|
case "a2": a2 = "X"; break;
|
|
case "a3": a3 = "X"; break;
|
|
case "a4": a4 = "X"; break;
|
|
case "a5": a5 = "X"; break;
|
|
case "a6": a6 = "X"; break;
|
|
case "a7": a7 = "X"; break;
|
|
case "a8": a8 = "X"; break;
|
|
case "b1": b1 = "X"; break;
|
|
case "b2": b2 = "X"; break;
|
|
case "b3": b3 = "X"; break;
|
|
case "b4": b4 = "X"; break;
|
|
case "b5": b5 = "X"; break;
|
|
case "b6": b6 = "X"; break;
|
|
case "b7": b7 = "X"; break;
|
|
case "b8": b8 = "X"; break;
|
|
case "c1": c1 = "X"; break;
|
|
case "c2": c2 = "X"; break;
|
|
case "c3": c3 = "X"; break;
|
|
case "c4": c4 = "X"; break;
|
|
case "c5": c5 = "X"; break;
|
|
case "c6": c6 = "X"; break;
|
|
case "c7": c7 = "X"; break;
|
|
case "c8": c8 = "X"; break;
|
|
case "d1": d1 = "X"; break;
|
|
case "d2": d2 = "X"; break;
|
|
case "d3": d3 = "X"; break;
|
|
case "d4": d4 = "X"; break;
|
|
case "d5": d5 = "X"; break;
|
|
case "d6": d6 = "X"; break;
|
|
case "d7": d7 = "X"; break;
|
|
case "d8": d8 = "X"; break;
|
|
case "e1": e1 = "X"; break;
|
|
case "e2": e2 = "X"; break;
|
|
case "e3": e3 = "X"; break;
|
|
case "e4": e4 = "X"; break;
|
|
case "e5": e5 = "X"; break;
|
|
case "e6": e6 = "X"; break;
|
|
case "e7": e7 = "X"; break;
|
|
case "e8": e8 = "X"; break;
|
|
case "f1": f1 = "X"; break;
|
|
case "f2": f2 = "X"; break;
|
|
case "f3": f3 = "X"; break;
|
|
case "f4": f4 = "X"; break;
|
|
case "f5": f5 = "X"; break;
|
|
case "f6": f6 = "X"; break;
|
|
case "f7": f7 = "X"; break;
|
|
case "f8": f8 = "X"; break;
|
|
case "g1": g1 = "X"; break;
|
|
case "g2": g2 = "X"; break;
|
|
case "g3": g3 = "X"; break;
|
|
case "g4": g4 = "X"; break;
|
|
case "g5": g5 = "X"; break;
|
|
case "g6": g6 = "X"; break;
|
|
case "g7": g7 = "X"; break;
|
|
case "g8": g8 = "X"; break;
|
|
case "h1": h1 = "X"; break;
|
|
case "h2": h2 = "X"; break;
|
|
case "h3": h3 = "X"; break;
|
|
case "h4": h4 = "X"; break;
|
|
case "h5": h5 = "X"; break;
|
|
case "h6": h6 = "X"; break;
|
|
case "h7": h7 = "X"; break;
|
|
case "h8": h8 = "X"; break;
|
|
}
|
|
}
|
|
else
|
|
{
|
|
switch (curCheckPos)
|
|
{
|
|
|
|
}
|
|
}
|
|
// Schleifen wiederholung um Anzahleroberungen zu reduzieren
|
|
}
|
|
}
|
|
|
|
}
|
|
|
|
// Überprüfen ob Siegbedingungen erfüllt
|
|
static void winningCheck (ref int anzXZuege, ref int anzOZuege, ref bool wincheck, ref string leadPlayer,
|
|
ref string a1, ref string b1, ref string c1, ref string d1, ref string e1, ref string f1, ref string g1, ref string h1,
|
|
ref string a2, ref string b2, ref string c2, ref string d2, ref string e2, ref string f2, ref string g2, ref string h2,
|
|
ref string a3, ref string b3, ref string c3, ref string d3, ref string e3, ref string f3, ref string g3, ref string h3,
|
|
ref string a4, ref string b4, ref string c4, ref string d4, ref string e4, ref string f4, ref string g4, ref string h4,
|
|
ref string a5, ref string b5, ref string c5, ref string d5, ref string e5, ref string f5, ref string g5, ref string h5,
|
|
ref string a6, ref string b6, ref string c6, ref string d6, ref string e6, ref string f6, ref string g6, ref string h6,
|
|
ref string a7, ref string b7, ref string c7, ref string d7, ref string e7, ref string f7, ref string g7, ref string h7,
|
|
ref string a8, ref string b8, ref string c8, ref string d8, ref string e8, ref string f8, ref string g8, ref string h8)
|
|
{
|
|
// hier checken ob noch überhaupt züge da sind -> wenn nein dann spiel vorbei und leadplayer ist sieger| anzahl möglicher züge pro spieler berechnen
|
|
// wenn ein spieler keine züge mehr hat muss pass erzwungen werden (gamemode 4 oder 5 je nach spieler)
|
|
}
|
|
|
|
// Zählen, wie viele von jeder Steinsorte auf dem Feld liegt
|
|
static void countField(ref int anzXSteine, ref int anzOSteine,
|
|
ref string a1, ref string b1, ref string c1, ref string d1, ref string e1, ref string f1, ref string g1, ref string h1,
|
|
ref string a2, ref string b2, ref string c2, ref string d2, ref string e2, ref string f2, ref string g2, ref string h2,
|
|
ref string a3, ref string b3, ref string c3, ref string d3, ref string e3, ref string f3, ref string g3, ref string h3,
|
|
ref string a4, ref string b4, ref string c4, ref string d4, ref string e4, ref string f4, ref string g4, ref string h4,
|
|
ref string a5, ref string b5, ref string c5, ref string d5, ref string e5, ref string f5, ref string g5, ref string h5,
|
|
ref string a6, ref string b6, ref string c6, ref string d6, ref string e6, ref string f6, ref string g6, ref string h6,
|
|
ref string a7, ref string b7, ref string c7, ref string d7, ref string e7, ref string f7, ref string g7, ref string h7,
|
|
ref string a8, ref string b8, ref string c8, ref string d8, ref string e8, ref string f8, ref string g8, ref string h8)
|
|
{
|
|
string curCheckPos = "a1";
|
|
char currSpalte;
|
|
int currReihe;
|
|
|
|
anzOSteine = 0;
|
|
anzXSteine = 0;
|
|
|
|
//Initialisieren der Startposition
|
|
currReihe = Convert.ToInt32(curCheckPos.Substring(1, 1));
|
|
|
|
for (; currReihe < 9; currReihe++)
|
|
{
|
|
//Setzen neue Startposition
|
|
currSpalte = 'a';
|
|
curCheckPos = currSpalte + Convert.ToString(currReihe);
|
|
|
|
for (int spalte = 1; spalte < 9; spalte++)
|
|
{
|
|
|
|
//Zählen der Feldinhalte zu X oder O
|
|
switch (curCheckPos)
|
|
{
|
|
case "a1": if (a1 == "O")
|
|
{ anzOSteine++; break; }
|
|
else if (a1 == "X")
|
|
{ anzXSteine++; break; }
|
|
else
|
|
continue;
|
|
case "a2":
|
|
if (a2 == "O")
|
|
{ anzOSteine++; break; }
|
|
else if (a2 == "X")
|
|
{ anzXSteine++; break; }
|
|
else
|
|
continue;
|
|
case "a3":
|
|
if (a3 == "O")
|
|
{ anzOSteine++; break; }
|
|
else if (a3 == "X")
|
|
{ anzXSteine++; break; }
|
|
else
|
|
continue;
|
|
case "a4":
|
|
if (a4 == "O")
|
|
{ anzOSteine++; break; }
|
|
else if (a4 == "X")
|
|
{ anzXSteine++; break; }
|
|
else
|
|
continue;
|
|
case "a5":
|
|
if (a5 == "O")
|
|
{ anzOSteine++; break; }
|
|
else if (a5 == "X")
|
|
{ anzXSteine++; break; }
|
|
else
|
|
continue;
|
|
case "a6":
|
|
if (a6 == "O")
|
|
{ anzOSteine++; break; }
|
|
else if (a6 == "X")
|
|
{ anzXSteine++; break; }
|
|
else
|
|
continue;
|
|
case "a7":
|
|
if (a7 == "O")
|
|
{ anzOSteine++; break; }
|
|
else if (a7 == "X")
|
|
{ anzXSteine++; break; }
|
|
else
|
|
continue;
|
|
case "a8":
|
|
if (a8 == "O")
|
|
{ anzOSteine++; break; }
|
|
else if (a8 == "X")
|
|
{ anzXSteine++; break; }
|
|
else
|
|
continue;
|
|
case "b1":
|
|
if (b1 == "O")
|
|
{ anzOSteine++; break; }
|
|
else if (b1 == "X")
|
|
{ anzXSteine++; break; }
|
|
else
|
|
continue;
|
|
case "b2":
|
|
if (b2 == "O")
|
|
{ anzOSteine++; break; }
|
|
else if (b2 == "X")
|
|
{ anzXSteine++; break; }
|
|
else
|
|
continue;
|
|
case "b3":
|
|
if (b3 == "O")
|
|
{ anzOSteine++; break; }
|
|
else if (b3 == "X")
|
|
{ anzXSteine++; break; }
|
|
else
|
|
continue;
|
|
case "b4":
|
|
if (b4 == "O")
|
|
{ anzOSteine++; break; }
|
|
else if (b4 == "X")
|
|
{ anzXSteine++; break; }
|
|
else
|
|
continue;
|
|
case "b5":
|
|
if (b5 == "O")
|
|
{ anzOSteine++; break; }
|
|
else if (b5 == "X")
|
|
{ anzXSteine++; break; }
|
|
else
|
|
continue;
|
|
case "b6":
|
|
if (b6 == "O")
|
|
{ anzOSteine++; break; }
|
|
else if (b6 == "X")
|
|
{ anzXSteine++; break; }
|
|
else
|
|
continue;
|
|
case "b7":
|
|
if (b7 == "O")
|
|
{ anzOSteine++; break; }
|
|
else if (b7 == "X")
|
|
{ anzXSteine++; break; }
|
|
else
|
|
continue;
|
|
case "b8":
|
|
if (b8 == "O")
|
|
{ anzOSteine++; break; }
|
|
else if (b8 == "X")
|
|
{ anzXSteine++; break; }
|
|
else
|
|
continue;
|
|
case "c1":
|
|
if (c1 == "O")
|
|
{ anzOSteine++; break; }
|
|
else if (c1 == "X")
|
|
{ anzXSteine++; break; }
|
|
else
|
|
continue;
|
|
case "c2":
|
|
if (c2 == "O")
|
|
{ anzOSteine++; break; }
|
|
else if (c2 == "X")
|
|
{ anzXSteine++; break; }
|
|
else
|
|
continue;
|
|
case "c3":
|
|
if (c3 == "O")
|
|
{ anzOSteine++; break; }
|
|
else if (c3 == "X")
|
|
{ anzXSteine++; break; }
|
|
else
|
|
continue;
|
|
case "c4":
|
|
if (c4 == "O")
|
|
{ anzOSteine++; break; }
|
|
else if (c4 == "X")
|
|
{ anzXSteine++; break; }
|
|
else
|
|
continue;
|
|
case "c5":
|
|
if (c5 == "O")
|
|
{ anzOSteine++; break; }
|
|
else if (c5 == "X")
|
|
{ anzXSteine++; break; }
|
|
else
|
|
continue;
|
|
case "c6":
|
|
if (c6 == "O")
|
|
{ anzOSteine++; break; }
|
|
else if (c6 == "X")
|
|
{ anzXSteine++; break; }
|
|
else
|
|
continue;
|
|
case "c7":
|
|
if (c7 == "O")
|
|
{ anzOSteine++; break; }
|
|
else if (c7 == "X")
|
|
{ anzXSteine++; break; }
|
|
else
|
|
continue;
|
|
case "c8":
|
|
if (c8 == "O")
|
|
{ anzOSteine++; break; }
|
|
else if (c8 == "X")
|
|
{ anzXSteine++; break; }
|
|
else
|
|
continue;
|
|
case "d1":
|
|
if (d1 == "O")
|
|
{ anzOSteine++; break; }
|
|
else if (d1 == "X")
|
|
{ anzXSteine++; break; }
|
|
else
|
|
continue;
|
|
case "d2":
|
|
if (d2 == "O")
|
|
{ anzOSteine++; break; }
|
|
else if (d2 == "X")
|
|
{ anzXSteine++; break; }
|
|
else
|
|
continue;
|
|
case "d3":
|
|
if (d3 == "O")
|
|
{ anzOSteine++; break; }
|
|
else if (d3 == "X")
|
|
{ anzXSteine++; break; }
|
|
else
|
|
continue;
|
|
case "d4":
|
|
if (d4 == "O")
|
|
{ anzOSteine++; break; }
|
|
else if (d4 == "X")
|
|
{ anzXSteine++; break; }
|
|
else
|
|
continue;
|
|
case "d5":
|
|
if (d5 == "O")
|
|
{ anzOSteine++; break; }
|
|
else if (d5 == "X")
|
|
{ anzXSteine++; break; }
|
|
else
|
|
continue;
|
|
case "d6":
|
|
if (d6 == "O")
|
|
{ anzOSteine++; break; }
|
|
else if (d6 == "X")
|
|
{ anzXSteine++; break; }
|
|
else
|
|
continue;
|
|
case "d7":
|
|
if (d7 == "O")
|
|
{ anzOSteine++; break; }
|
|
else if (d7 == "X")
|
|
{ anzXSteine++; break; }
|
|
else
|
|
continue;
|
|
case "d8":
|
|
if (d8 == "O")
|
|
{ anzOSteine++; break; }
|
|
else if (d8 == "X")
|
|
{ anzXSteine++; break; }
|
|
else
|
|
continue;
|
|
case "e1":
|
|
if (e1 == "O")
|
|
{ anzOSteine++; break; }
|
|
else if (e1 == "X")
|
|
{ anzXSteine++; break; }
|
|
else
|
|
continue;
|
|
case "e2":
|
|
if (e2 == "O")
|
|
{ anzOSteine++; break; }
|
|
else if (e2 == "X")
|
|
{ anzXSteine++; break; }
|
|
else
|
|
continue;
|
|
case "e3":
|
|
if (e3 == "O")
|
|
{ anzOSteine++; break; }
|
|
else if (e3 == "X")
|
|
{ anzXSteine++; break; }
|
|
else
|
|
continue;
|
|
case "e4":
|
|
if (e4 == "O")
|
|
{ anzOSteine++; break; }
|
|
else if (e4 == "X")
|
|
{ anzXSteine++; break; }
|
|
else
|
|
continue;
|
|
case "e5":
|
|
if (e5 == "O")
|
|
{ anzOSteine++; break; }
|
|
else if (e5 == "X")
|
|
{ anzXSteine++; break; }
|
|
else
|
|
continue;
|
|
case "e6":
|
|
if (e6 == "O")
|
|
{ anzOSteine++; break; }
|
|
else if (e6 == "X")
|
|
{ anzXSteine++; break; }
|
|
else
|
|
continue;
|
|
case "e7":
|
|
if (e7 == "O")
|
|
{ anzOSteine++; break; }
|
|
else if (e7 == "X")
|
|
{ anzXSteine++; break; }
|
|
else
|
|
continue;
|
|
case "e8":
|
|
if (e8 == "O")
|
|
{ anzOSteine++; break; }
|
|
else if (e8 == "X")
|
|
{ anzXSteine++; break; }
|
|
else
|
|
continue;
|
|
case "f1":
|
|
if (f1 == "O")
|
|
{ anzOSteine++; break; }
|
|
else if (f1 == "X")
|
|
{ anzXSteine++; break; }
|
|
else
|
|
continue;
|
|
case "f2":
|
|
if (f2 == "O")
|
|
{ anzOSteine++; break; }
|
|
else if (f2 == "X")
|
|
{ anzXSteine++; break; }
|
|
else
|
|
continue;
|
|
case "f3":
|
|
if (f3 == "O")
|
|
{ anzOSteine++; break; }
|
|
else if (f3 == "X")
|
|
{ anzXSteine++; break; }
|
|
else
|
|
continue;
|
|
case "f4":
|
|
if (f4 == "O")
|
|
{ anzOSteine++; break; }
|
|
else if (f4 == "X")
|
|
{ anzXSteine++; break; }
|
|
else
|
|
continue;
|
|
case "f5":
|
|
if (f5 == "O")
|
|
{ anzOSteine++; break; }
|
|
else if (f5 == "X")
|
|
{ anzXSteine++; break; }
|
|
else
|
|
continue;
|
|
case "f6":
|
|
if (f6 == "O")
|
|
{ anzOSteine++; break; }
|
|
else if (f6 == "X")
|
|
{ anzXSteine++; break; }
|
|
else
|
|
continue;
|
|
case "f7":
|
|
if (f7 == "O")
|
|
{ anzOSteine++; break; }
|
|
else if (f7 == "X")
|
|
{ anzXSteine++; break; }
|
|
else
|
|
continue;
|
|
case "f8":
|
|
if (f8 == "O")
|
|
{ anzOSteine++; break; }
|
|
else if (f8 == "X")
|
|
{ anzXSteine++; break; }
|
|
else
|
|
continue;
|
|
case "g1":
|
|
if (g1 == "O")
|
|
{ anzOSteine++; break; }
|
|
else if (g1 == "X")
|
|
{ anzXSteine++; break; }
|
|
else
|
|
continue;
|
|
case "g2":
|
|
if (g2 == "O")
|
|
{ anzOSteine++; break; }
|
|
else if (g2 == "X")
|
|
{ anzXSteine++; break; }
|
|
else
|
|
continue;
|
|
case "g3":
|
|
if (g3 == "O")
|
|
{ anzOSteine++; break; }
|
|
else if (g3 == "X")
|
|
{ anzXSteine++; break; }
|
|
else
|
|
continue;
|
|
case "g4":
|
|
if (g4 == "O")
|
|
{ anzOSteine++; break; }
|
|
else if (g4 == "X")
|
|
{ anzXSteine++; break; }
|
|
else
|
|
continue;
|
|
case "g5":
|
|
if (g5 == "O")
|
|
{ anzOSteine++; break; }
|
|
else if (g5 == "X")
|
|
{ anzXSteine++; break; }
|
|
else
|
|
continue;
|
|
case "g6":
|
|
if (g6 == "O")
|
|
{ anzOSteine++; break; }
|
|
else if (g6 == "X")
|
|
{ anzXSteine++; break; }
|
|
else
|
|
continue;
|
|
case "g7":
|
|
if (g7 == "O")
|
|
{ anzOSteine++; break; }
|
|
else if (g7 == "X")
|
|
{ anzXSteine++; break; }
|
|
else
|
|
continue;
|
|
case "g8":
|
|
if (g8 == "O")
|
|
{ anzOSteine++; break; }
|
|
else if (g8 == "X")
|
|
{ anzXSteine++; break; }
|
|
else
|
|
continue;
|
|
case "h1":
|
|
if (h1 == "O")
|
|
{ anzOSteine++; break; }
|
|
else if (h1 == "X")
|
|
{ anzXSteine++; break; }
|
|
else
|
|
continue;
|
|
case "h2":
|
|
if (h2 == "O")
|
|
{ anzOSteine++; break; }
|
|
else if (h2 == "X")
|
|
{ anzXSteine++; break; }
|
|
else
|
|
continue;
|
|
case "h3":
|
|
if (h3 == "O")
|
|
{ anzOSteine++; break; }
|
|
else if (h3 == "X")
|
|
{ anzXSteine++; break; }
|
|
else
|
|
continue;
|
|
case "h4":
|
|
if (h4 == "O")
|
|
{ anzOSteine++; break; }
|
|
else if (h4 == "X")
|
|
{ anzXSteine++; break; }
|
|
else
|
|
continue;
|
|
case "h5":
|
|
if (h5 == "O")
|
|
{ anzOSteine++; break; }
|
|
else if (h5 == "X")
|
|
{ anzXSteine++; break; }
|
|
else
|
|
continue;
|
|
case "h6":
|
|
if (h6 == "O")
|
|
{ anzOSteine++; break; }
|
|
else if (h6 == "X")
|
|
{ anzXSteine++; break; }
|
|
else
|
|
continue;
|
|
case "h7":
|
|
if (h7 == "O")
|
|
{ anzOSteine++; break; }
|
|
else if (h7 == "X")
|
|
{ anzXSteine++; break; }
|
|
else
|
|
continue;
|
|
case "h8":
|
|
if (h8 == "O")
|
|
{ anzOSteine++; break; }
|
|
else if (h8 == "X")
|
|
{ anzXSteine++; break; }
|
|
else
|
|
continue;
|
|
}
|
|
|
|
|
|
if (spalte != 8)
|
|
{
|
|
//bewegen nach rechts auf dem Feld
|
|
currSpalte = (char)(currSpalte + 1);
|
|
curCheckPos = currSpalte + Convert.ToString(currReihe); break;
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|
|
}
|
|
}
|
|
|
|
}
|
|
|