AI plays development cards
Signed-off-by: James Ketrenos <james_eikona@ketrenos.com>
This commit is contained in:
parent
054849067a
commit
8aae5480b8
@ -5,7 +5,6 @@ const calculateLongestRoad = require('./longest-road.js');
|
|||||||
|
|
||||||
const { getValidRoads, getValidCorners } = require('../util/validLocations.js');
|
const { getValidRoads, getValidCorners } = require('../util/validLocations.js');
|
||||||
const { layout, staticData } = require('../util/layout.js');
|
const { layout, staticData } = require('../util/layout.js');
|
||||||
const { turn } = require('core-js/core/array');
|
|
||||||
|
|
||||||
const version = '0.0.1';
|
const version = '0.0.1';
|
||||||
|
|
||||||
@ -30,7 +29,6 @@ const anyValue = undefined;
|
|||||||
|
|
||||||
process.env["NODE_TLS_REJECT_UNAUTHORIZED"] = 0;
|
process.env["NODE_TLS_REJECT_UNAUTHORIZED"] = 0;
|
||||||
|
|
||||||
|
|
||||||
/* Do not use arrow function as this is rebound to have
|
/* Do not use arrow function as this is rebound to have
|
||||||
* this as the WebSocket */
|
* this as the WebSocket */
|
||||||
let send = function (data) {
|
let send = function (data) {
|
||||||
@ -193,6 +191,43 @@ const tryBuild = () => {
|
|||||||
return waitingFor;
|
return waitingFor;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
|
const tryProgress = () => {
|
||||||
|
let waitingFor = undefined;
|
||||||
|
|
||||||
|
if (!game.private.development) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
let vps = 0;
|
||||||
|
for (let i = 0; i < game.private.development.length; i++) {
|
||||||
|
const card = game.private.development[i];
|
||||||
|
if (card.turn >= game.turns || card.played || card.type === 'vp') {
|
||||||
|
if (card.type === 'vp') vps++;
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
|
||||||
|
console.log(`${name} - Playing -`, card);
|
||||||
|
send({
|
||||||
|
type: 'play-card',
|
||||||
|
card
|
||||||
|
});
|
||||||
|
|
||||||
|
return {
|
||||||
|
turn: {
|
||||||
|
actions: anyValue
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if (vps) {
|
||||||
|
send({
|
||||||
|
type: 'chat',
|
||||||
|
message: `I have ${vps} VP cards!`
|
||||||
|
});
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
let sleeping = false;
|
let sleeping = false;
|
||||||
let paused = false;
|
let paused = false;
|
||||||
|
|
||||||
@ -656,6 +691,12 @@ const processNormal = async (received) => {
|
|||||||
private: anyValue
|
private: anyValue
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
|
if (!game.pipOrder) {
|
||||||
|
return {
|
||||||
|
pipOrder: anyValue
|
||||||
|
};
|
||||||
|
}
|
||||||
|
|
||||||
/* Process things that happen on everyone's turn */
|
/* Process things that happen on everyone's turn */
|
||||||
waitingFor = await processDiscard(received);
|
waitingFor = await processDiscard(received);
|
||||||
@ -775,6 +816,11 @@ const processNormal = async (received) => {
|
|||||||
if (waitingFor) {
|
if (waitingFor) {
|
||||||
return waitingFor;
|
return waitingFor;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
waitingFor = await tryProgress(received);
|
||||||
|
if (waitingFor) {
|
||||||
|
return waitingFor;
|
||||||
|
}
|
||||||
|
|
||||||
waitingFor = await processTrade(received);
|
waitingFor = await processTrade(received);
|
||||||
if (waitingFor) {
|
if (waitingFor) {
|
||||||
|
Loading…
x
Reference in New Issue
Block a user