Skip to content

Instantly share code, notes, and snippets.

View atoko's full-sized avatar
🦈
🧶💻

atoko

🦈
🧶💻
View GitHub Profile
function* forwardEventsToReducer(channel) {
while (true) {
const action = yield take(channel);
yield put(action);
}
}
function* watchLogins() {
while (true) {
let shuffle = function(array) {
for (var c = array.length - 1; c > 1; c--) {
var r = (Math.random() * c).toFixed(0);
var one = array[r];
var two = array[c];
if (one !== null) {
array[c] = one;
import {combineReducers} from 'redux';
import battleEngine, {BOT_IDENTIFIER} from './briscaEngine';
import * as actions from './briscaActions';
const defaultState = () => {
return {
deck: [],
rounds: [],
tableSize: 0,
tableOwner: null,
Odd little known fact: in 1963 when there were no degrees in computer science, NCR did a study to find out what degrees would the people with computer science aptitude be likely to have. they were surprised by the result: english and music. After some thought they realized that both are people who can be creative within very defined constraints.
import React from 'react';
import { storiesOf } from '@storybook/react';
import Provider, {initialState} from './util/provider';
import LanguageProvider from '../src/App/hoc/language';
import Game from '../src/App/game';
import * as GameActions from '../src/store/brisca/actions';
let GameWithLanguage = (props) => {
return (<LanguageProvider><Game {...props} /></LanguageProvider>);
export const GAME_HEIGHT = 32;
export const GAME_WIDTH = 32;
export const moveSnake = ({x, y}) => ({
type: "MOVE_SNAKE",
xVelocity: x,
yVelocity: y
});
export const spawnDot = ({x = Math.random() * GAME_WIDTH, y = Math.random() * GAME_HEIGHT}) => ({
import groovyjarjarantlr.collections.List
class BriscaData {
static Map suits = [
0: "Coins",
1: "Staffs",
2: "Goblets",
3: "Swords"
]
static Map faces = [
//Requires React, Redux installed
//Requires Pure Briscas, found at https://gist.github.com/atoko/39e5b0ceb2778a3b456c73e2ed082156
import { createStore, combineReducers } from 'redux';
import Brisca from './lib/brisca';
import React from 'react';
import ReactDOM from 'react-dom';
import {
range,
shuffle
} from "./deckUtil";
class BriscaEngine {
constructor(deck) {
this.life = this.determineSuit(deck[0]);
this.pointMapping = {
0: 11,
2: 10,
#indent "off"
type Suit =
|Oro |Basto |Copa |Espada
type Face =
|I |II |III |IV |V |VI |VII |X |XI |XII
type Card = Suit * Face
type BriscaCard = {card:Card; isLife:bool;}
let BriscaValue (c : BriscaCard) =
match c.card with