lucas-ifsp / ctruco Goto Github PK
View Code? Open in Web Editor NEWTruco game for didactic purposes
License: GNU General Public License v3.0
Truco game for didactic purposes
License: GNU General Public License v3.0
when vira is 3 and manilha is 4, relative values are not shifted properly, making so cards 5~3 are valued at 2~10 instead of 1~9, and a 3 has the same value as a diamonds 4 (manilha)
related code @com/bueno/spi/model/TrucoCard.java:
public int relativeValue(TrucoCard vira) {
Objects.requireNonNull(vira, "Vira card must not be null.");
if (isManilha(vira))
return switch (suit) {
case DIAMONDS -> 10;
case SPADES -> 11;
case HEARTS -> 12;
case CLUBS -> 13;
case HIDDEN -> throw new IllegalStateException("Closed card can not be manilha!");
};
if(rank.value() > vira.rank.value()) return rank.value() - 1;
return rank.value();
}
test that i made that fails:
@Test
@DisplayName("Should 3 have a relative value of 9 when 3 is vira and 4 is manilha")
void shouldThreeHaveRelativeValueOfNineWhenThreeIsVira(){
TrucoCard vira = TrucoCard.of(THREE, SPADES);
TrucoCard three = TrucoCard.of(THREE, DIAMONDS);
assertEquals(9, three.relativeValue(vira));
}
org.opentest4j.AssertionFailedError:
Expected :9
Actual :10
potential fix:
public int relativeValue(TrucoCard vira) {
Objects.requireNonNull(vira, "Vira card must not be null.");
if (isManilha(vira))
return switch (suit) {
case DIAMONDS -> 10;
case SPADES -> 11;
case HEARTS -> 12;
case CLUBS -> 13;
case HIDDEN -> throw new IllegalStateException("Closed card can not be manilha!");
};
if(rank.value() > vira.rank.value()) return rank.value() - 1;
if(vira.rank.value() == 10) return rank.value() - 1;
return rank.value();
}
Não sei se é um bug ou uma falha na implementação do Bot, mas há momentos em que meu bot tenta aumentar a aposta, de 6 para 9, ou seja, o evento RAISE, porém a instância de Intel(utilizada no método playWithBots da classe PlayWithBotsUseCase) diz que não é possível lançar um evento RAISE uma vez que a lista de strings retornada no método possibleActions é ["QUIT", "ACCEPT"].
Seria alguma regra do Truco que não estou sabendo?
A imagem abaixo ilustra o estado da instância da classe Intel
Na execução interativa no terminal, na primeira rodada do jogo é permitido descartar a carta
Teste
A declarative, efficient, and flexible JavaScript library for building user interfaces.
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google ❤️ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.