Commit 37bba758 authored by Erreiip's avatar Erreiip
Browse files

oh pinaise

parent da24e049
Loading
Loading
Loading
Loading
+24 −12
Changes for jeuAssemblage/src/bot/BotThread.java: 24 added lines, 12 removed lines.
Original line number Diff line number Diff line
@@ -9,28 +9,28 @@ public class BotThread implements Runnable {
    
    private final static int DEFAULT_SLEEP = 1000;

    private ArrayList<IBot> bot;
    private int sleepTime;

    private IMovesView movesView;
    private ArrayList<IBot> bots;
    private ArrayList<IMovesView> movesViews;

    private boolean stop;

    public BotThread(ArrayList<IBot> bot, IMovesView movesView) {
    public BotThread(ArrayList<IBot> bots, ArrayList<IMovesView> movesViews) {

        this(bot, DEFAULT_SLEEP, movesView);
        this(bots, DEFAULT_SLEEP, movesViews);
    }

    public BotThread(ArrayList<IBot> bot, int sleepTime, IMovesView movesView) {
    public BotThread(ArrayList<IBot> bots, int sleepTime, ArrayList<IMovesView> movesViews) {

        this.bot = bot;
        this.bots = bots;
        this.sleepTime = sleepTime;
        this.movesView = movesView;
        this.movesViews = movesViews;
        this.stop = false;
    }

    public ArrayList<IBot> getBots() {
        return this.bot;
        return this.bots;
    }

    public void stop() {
@@ -44,14 +44,26 @@ public class BotThread implements Runnable {
    @Override
    public void run() {

        while (!this.stop && bot.tick()) {
        while (!this.stop) {
            boolean stopable = true;

            for ( int i = 0; i < this.bots.size(); i++) {
                IBot bot = this.bots.get(i);
                IMovesView movesView = this.movesViews.get(i);
                
                if ( bot.tick() ) {
                    stopable = false;
                } else {
                    movesView.start();
                }
            }

            if ( stopable ) this.stop();

            try { Thread.sleep(sleepTime); }
            catch(Exception e ) { e.printStackTrace(); }        
        }
        
        this.movesView.setMoves(this.bot.getMoves());
        this.movesView.start();
        
        this.stop();
    }

+3 −3
Changes for jeuAssemblage/src/bot/utils/Move.java: 3 added lines, 3 removed lines.
Original line number Diff line number Diff line
@@ -4,9 +4,9 @@ import piece.Piece;

public class Move {
    
    protected int pieceId;
    protected int x;
    protected int y;
    public int pieceId;
    public int x;
    public int y;

    public Move(int pieceId, int x, int y) {
        this.pieceId = pieceId;
+49 −0
Changes for jeuAssemblage/src/bot/view/MovesToIHM.java: 49 added lines, 0 removed lines.
Original line number Diff line number Diff line
package bot.view;

import java.util.ArrayList;
import java.util.LinkedList;
import java.util.List;

import bot.interfaces.IBot;
import bot.utils.Move;
import bot.view.interfaces.IMovableView;
import bot.view.interfaces.IMovesView;

public class MovesToIHM implements IMovesView {

    private IBot bot;
    private IMovableView view;

    public MovesToIHM(IBot bot, IMovableView view) {

        this.bot = bot;
        this.view = view;
    }

    @Override
    public void start() {
        List<Move> alMoves = (ArrayList<Move>) this.bot.getMoves();
        List<Move> alMovesNotCheck = new ArrayList<Move>();

        do {
            
            for (int i = 0; i < alMoves.size(); i++) {
                Move m = alMoves.get(i);

                this.view.moveMouseOn(m.pieceId);
                this.view.click();
                this.view.moveMouseOn(m.x, m.y);
                
                if ( !this.view.placePiece() ) {
                    alMovesNotCheck.add(m);
                }
            }

            alMoves = alMovesNotCheck;
            alMovesNotCheck = new ArrayList<Move>();

        } while( ! alMoves.isEmpty() );
    }
    
    
}
+0 −42
Changes for jeuAssemblage/src/bot/view/MovesToView.java: 0 added lines, 42 removed lines.
Original line number Diff line number Diff line
package bot.view;

import java.util.LinkedList;
import java.util.List;

import bot.utils.Move;
import bot.view.interfaces.IMovableView;
import bot.view.interfaces.IMovesView;

public class MovesToView implements IMovesView {

    List<Move> moves;
    IMovableView view;

    public MovesToView(IMovableView view) {

        this(new LinkedList<Move>(), view);
    }

    public MovesToView(List<Move> moves, IMovableView view) {

        this.moves = moves;
        this.view = view;
    }

    @Override
    public void setMoves(List<Move> lstMoves) {
        
        this.moves = lstMoves;
    }

    @Override
    public void start() {
        
        for (Move m : this.moves) {
            //this.view.moveMouseOn(m.)
        }
        throw new UnsupportedOperationException("Unimplemented method 'start'");
    }
    
    
}
+6 −0
Changes for jeuAssemblage/src/bot/view/interfaces/IMovableView.java: 6 added lines, 0 removed lines.
Original line number Diff line number Diff line
package bot.view.interfaces;

import piece.Piece;

public interface IMovableView {
       
    public abstract void moveMouseOn(int pieceId);
    public abstract void moveMouseOn(int x, int y);
    public abstract void click();
    public abstract boolean placePiece();
}
Loading