Giter Site home page Giter Site logo

applysci / aim Goto Github PK

View Code? Open in Web Editor NEW
0.0 0.0 1.0 18.45 MB

All-Ireland Mahjong mobile app

Kotlin 0.02% Swift 0.59% Objective-C 0.01% Dart 28.87% CMake 3.34% C++ 4.26% C 2.68% HTML 5.94% Python 52.55% Batchfile 0.01% CSS 1.11% Shell 0.15% Ruby 0.48%

aim's People

Contributors

applysci avatar energynumbers avatar

Watchers

 avatar  avatar  avatar

Forkers

north101

aim's Issues

server-side: have a straightforward way to change the number of tables

two parts:

  1. change it before the tournament starts - fairly easy - just use one of the standard templates. May need to check assigned seating numbers are contiguous 1-N.

  2. change it after at least one round has been played - much more difficult. For this, we need to track substitutes, and need to reassign seating to minimise collisions. There's a crude starting point in https://github.com/ApplySci/aim/blob/main/server/run/reassign.py

Back button doesn't feel predictable

I rarely want to go to the all tournaments page, but it might still be good to have a dedicated button for it, rather than the back button sometimes going there, and not always when expected.

Also, not sure about losing the bottom tabs when going into player profile or hanchan results page.

API suggestions

so this is what i'm thinking, its written in typescript but i can convert it to something else if you're not familiar with it.

type PlayerId = number

// same as current
interface Player {
  id: PlayerId
  name: string
}

// players store
// same as current
type PlayersCollection = Player[]

type TournamentId = string

// same as current
interface Tournament {
  id: TournamentId
  name: string
  address: string
  country: string
  startDate: string
  endDate: string
  status: string
  rules: string
}

// tournaments store
// same as current
type TournamentsCollection = Tournament[]

type RoundId = string
type TableId = string

// schedule store
// combined Schedule + seating
interface ScheduleCollection {
  timezone: string
  rounds: {
    id: RoundId
    name: string
    start: string
    tables: {
      id: TableId
      name: string
      players: [
        PlayerId,
        PlayerId,
        PlayerId,
        PlayerId,
      ]
    }[]
  }[]
}

class PlayerRoundScore {
  score: number
  penalties: number
  uma: number
  position: number
  rank: number
  tied: boolean

  get finalScore(): number {
    return this.score - this.penalties + this.uma
  }
}

class PlayerScore {
  id: PlayerId
   // is it too much info to get this per round?
  rounds: PlayerRoundScore[]

  get score(): number {
    return this.rounds.reduce((value, round) => value + round.score, 0)
  }
  get penalties(): number {
    return this.rounds.reduce((value, round) => value + round.penalties, 0)
  }
  get finalScore(): number {
    return this.rounds.reduce((value, round) => value + round.finalScore, 0)
  }
  rank(roundIndex: number): number | undefined {
    return this.rounds[roundIndex]?.rank
  }
  tied(roundIndex: number): boolean {
    return this.rounds[roundIndex]?.tied ?? false
  }
}

// scores store
type ScoresCollection = PlayerScore[]

// calculate roundsDone like this:
let scoresCollection: PlayerScore[] = []
const roundsDone = () => scoresCollection.reduce<number | null>(
  (value, playerScore) => value != null
    ? Math.min(value, playerScore.rounds.length)
    : playerScore.rounds.length,
  null,
) ?? 0

As json doesn't support non-string keys, my preference is to return lists with the id instead. This means the client doesn't need to do any unnecessary conversion and ids are always consistently typed.

Looking at the docs for firestore, it looks like they support nested json. Is there any reason you're converting to a json string? I've not used firestore so maybe there is some limitation i'm unaware of.

handling substitute players

it's taken quite some special handling to be able to deal with substitutes. I don't like it, and we should definitely look at this again.

It messes up the whole existing paradigm.

there's now a dummy table created, server-side, called "missing", to handle players that don't appear at any table.

See [server/run/run.py#L358]

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.