GithubHelp home page GithubHelp logo

lucas-ifsp / ctruco Goto Github PK

View Code? Open in Web Editor NEW
11.0 1.0 66.0 11.26 MB

Truco game for didactic purposes

License: GNU General Public License v3.0

Java 100.00%
tdd ddd solid clean-code clean-architechture java-17

ctruco's Issues

RelativeValue calculated improperly when vira is 3

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 é possível aumentar o tento em jogo de Bot contra Bot

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

image.png

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.