-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathTabuleiro.cs
80 lines (73 loc) · 2.49 KB
/
Tabuleiro.cs
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
using Microsoft.Win32;
using System;
using System.Collections.Generic;
using System.Diagnostics.SymbolStore;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace TrabalhoPratico1
{
/// <summary>
/// Fornece funções uteis relacionadas ao tabuleiro do jogo Ludo.
/// </summary>
internal class Tabuleiro
{
/// <summary>
/// Encontra a próxima fileira no tabuleiro Ludo.
/// </summary>
/// <returns>Próxima fileira em relação a fileira recebida</returns>
public static string EncontrarProximaFileira(string nomeDaFileira)
{
nomeDaFileira = nomeDaFileira.ToLower();
switch (nomeDaFileira)
{
case "amarelo": return "azul";
case "azul": return "vermelho";
case "vermelho": return "verde";
case "verde": return "amarelo";
default: return null;
}
}
/// <summary>
/// Verifica se a posição recebida é uma casa segura.
/// </summary>
public static bool VerificarCasaSegura (int posicao)
{
//Obtem a posição do peão na sua fileira atual
int POS = posicao % 13;
//0 - começo da fileira
//8 - estrela
// >=51 reta final
if (POS == 0 || POS == 8 || posicao >= 51)
return true;
else
return false;
}
/// <summary>
/// Verifica se determinado peão capturou algum outro peão.
/// </summary>
/// <returns>Peão capturado ou null se não houver.</returns>
public static Peao VerificarCaptura (Peao peao)
{
int POS = peao.Posicao;
if (peao.EstaSeguro == true)
return null;
for (int i = 0; i < Jogo.QtdJogadores; i++)
{
Jogador jogador = Jogo.Jogadores[i];
if (peao.Cor == jogador.Cor)
continue;
for (int j = 0; j < jogador.MeusPeoes.Length; j++)
{
if (jogador.MeusPeoes[j].Posicao % 13 == (POS % 13) &&
jogador.MeusPeoes[j].FileiraAtual == peao.FileiraAtual &&
jogador.MeusPeoes[j].EstaFinalizando == false)
{
return jogador.MeusPeoes[j];
}
}
}
return null;
}
}
}