Git Product home page Git Product logo

battlechess's People

Contributors

dependabot[bot] avatar guyver2 avatar polmonso avatar quimnuss avatar sandroretinai avatar

Stargazers

 avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar

battlechess's Issues

Board' object has no attribute 'dbpiece2board

  File "./server/btchApi.py", line 317, in post_move
    snap = crud.create_snap_by_move(db, current_user, game, gameMove)
  File "./server/crud.py", line 175, in create_snap_by_move
    snapOptions = game.moveGame(gameMove.move)
  File "./server/models.py", line 117, in moveGame
    new_snap_options = current_snap.moveSnap(move)
  File "./server/models.py", line 178, in moveSnap
    board = self.toBoard()
  File "./server/models.py", line 205, in toBoard
    board.updateFromElements(self.board, self.taken, self.castelable, enpassant, winner)
  File "./core/Board.py", line 550, in updateFromElements
    self.taken = [self.dbpiece2board(c) for c in taken]
  File "./core/Board.py", line 550, in <listcomp>
    self.taken = [self.dbpiece2board(c) for c in taken]
AttributeError: 'Board' object has no attribute 'dbpiece2board'

Error fetching finished games

The following internal server error happens when the user issuing the query has finished games

INFO:     31.10.154.26:52836 - "GET /users/me/games/ HTTP/1.1" 500 Internal Server Error
2021-05-26 20:22:27,521 INFO sqlalchemy.engine.Engine ROLLBACK
ERROR:    Exception in ASGI application
Traceback (most recent call last):
  File "/usr/local/lib/python3.6/site-packages/uvicorn/protocols/http/h11_impl.py", line 396, in run_asgi
    result = await app(self.scope, self.receive, self.send)
  File "/usr/local/lib/python3.6/site-packages/uvicorn/middleware/proxy_headers.py", line 45, in __call__
    return await self.app(scope, receive, send)
  File "/usr/local/lib/python3.6/site-packages/fastapi/applications.py", line 199, in __call__
    await super().__call__(scope, receive, send)
  File "/usr/local/lib/python3.6/site-packages/starlette/applications.py", line 111, in __call__
    await self.middleware_stack(scope, receive, send)
  File "/usr/local/lib/python3.6/site-packages/starlette/middleware/errors.py", line 181, in __call__
    raise exc from None
  File "/usr/local/lib/python3.6/site-packages/starlette/middleware/errors.py", line 159, in __call__
    await self.app(scope, receive, _send)
  File "/usr/local/lib/python3.6/site-packages/starlette/middleware/cors.py", line 78, in __call__
    await self.app(scope, receive, send)
  File "/usr/local/lib/python3.6/site-packages/starlette/exceptions.py", line 82, in __call__
    raise exc from None
  File "/usr/local/lib/python3.6/site-packages/starlette/exceptions.py", line 71, in __call__
    await self.app(scope, receive, sender)
  File "/usr/local/lib/python3.6/site-packages/starlette/routing.py", line 566, in __call__
    await route.handle(scope, receive, send)
  File "/usr/local/lib/python3.6/site-packages/starlette/routing.py", line 227, in handle
    await self.app(scope, receive, send)
  File "/usr/local/lib/python3.6/site-packages/starlette/routing.py", line 41, in app
    response = await func(request)
  File "/usr/local/lib/python3.6/site-packages/fastapi/routing.py", line 218, in app
    is_coroutine=is_coroutine,
  File "/usr/local/lib/python3.6/site-packages/fastapi/routing.py", line 126, in serialize_response
    raise ValidationError(errors, field.type_)
pydantic.error_wrappers.ValidationError: 1 validation error for Game
response -> 0 -> turn
  none is not an allowed value (type=type_error.none.not_allowed)

Remove information leakage on movement error

ATM Board gives different error messages if one player tries to move and is blocked, the piece isn't his etc.
Potentially, a player could send a move on an enemy square and know wether there's a piece there or not.

These messages are very nice for debugging, but should be silenced/uniformized in "production" mode.

Flip board for balck player

When a player is black, the board should be flipped upside-down so that he also sees his pieces at the bottom of the screen

BTCH 2.0 Features discussion

Lets sit down and discuss what was missing form v1.0.

The main issues were:

  • Not being able to choose your opponent
  • No support for asynchronous games
  • No user account
  • Weird string based network protocol

I guess everyone agrees we should go with a headless server that provides a json based REST API.

What use scenarios I think we need for a fair reboot:

  • user creates an account
  • user logs in
  • user updates account
  • user send an invite to another user
  • user lists his invites
  • user accepts an invite (a new game is created)
  • user asks for random opponent (if one is available, a game is created)
  • user lists his games (both active and finished)
  • user retrieves game state + history
  • user sends a move to a game
  • anyone lists/searches finished games

If we manage to agree on an initial set of features, we could then design a database structure to hold all the information.

@quimnuss @Geniedesalpages opinion ?

API should not allow for empty username or password

Today the API accepts user creation with empty username or password.

we should limit that with the following rules for user creation

  • username betwen 3 and 15 chars
  • password at least 8 chars
  • email and full name can be left empty

need a /users/{useruuid}

We need a endpoint that returns only a single user based on its uuid.
So far if we want a user info we need to query all users :/

Castelable is not implemented

Starting a new game and requesting the possible moves for the king returns an error

INFO:     194.230.158.218:49692 - "GET /games/hxjktq/moves/e1 HTTP/1.1" 500 Internal Server Error
2021-05-22 17:18:03,818 INFO sqlalchemy.engine.Engine ROLLBACK
ERROR:    Exception in ASGI application
Traceback (most recent call last):
  File "/usr/local/lib/python3.6/site-packages/uvicorn/protocols/http/h11_impl.py", line 396, in run_asgi
    result = await app(self.scope, self.receive, self.send)
  File "/usr/local/lib/python3.6/site-packages/uvicorn/middleware/proxy_headers.py", line 45, in __call__
    return await self.app(scope, receive, send)
  File "/usr/local/lib/python3.6/site-packages/fastapi/applications.py", line 199, in __call__
    await super().__call__(scope, receive, send)
  File "/usr/local/lib/python3.6/site-packages/starlette/applications.py", line 111, in __call__
    await self.middleware_stack(scope, receive, send)
  File "/usr/local/lib/python3.6/site-packages/starlette/middleware/errors.py", line 181, in __call__
    raise exc from None
  File "/usr/local/lib/python3.6/site-packages/starlette/middleware/errors.py", line 159, in __call__
    await self.app(scope, receive, _send)
  File "/usr/local/lib/python3.6/site-packages/starlette/middleware/cors.py", line 86, in __call__
    await self.simple_response(scope, receive, send, request_headers=headers)
  File "/usr/local/lib/python3.6/site-packages/starlette/middleware/cors.py", line 142, in simple_response
    await self.app(scope, receive, send)
  File "/usr/local/lib/python3.6/site-packages/starlette/exceptions.py", line 82, in __call__
    raise exc from None
  File "/usr/local/lib/python3.6/site-packages/starlette/exceptions.py", line 71, in __call__
    await self.app(scope, receive, sender)
  File "/usr/local/lib/python3.6/site-packages/starlette/routing.py", line 566, in __call__
    await route.handle(scope, receive, send)
  File "/usr/local/lib/python3.6/site-packages/starlette/routing.py", line 227, in handle
    await self.app(scope, receive, send)
  File "/usr/local/lib/python3.6/site-packages/starlette/routing.py", line 41, in app
    response = await func(request)
  File "/usr/local/lib/python3.6/site-packages/fastapi/routing.py", line 202, in app
    dependant=dependant, values=values, is_coroutine=is_coroutine
  File "/usr/local/lib/python3.6/site-packages/fastapi/routing.py", line 150, in run_endpoint_function
    return await run_in_threadpool(dependant.call, **values)
  File "/usr/local/lib/python3.6/site-packages/starlette/concurrency.py", line 34, in run_in_threadpool
    return await loop.run_in_executor(None, func, *args)
  File "/usr/lib64/python3.6/concurrent/futures/thread.py", line 56, in run
    result = self.fn(*self.args, **self.kwargs)
  File "./server/btchApi.py", line 355, in get_moves
    moves = snap.getPossibleMoves(square, color)
  File "./server/models.py", line 228, in getPossibleMoves
    ijmoves = board.possibleMoves(color, i, j)
  File "./core/btchBoard.py", line 211, in possibleMoves
    moves = list(self.kingMoves(color, i, j))
  File "./core/btchBoard.py", line 270, in kingMoves
    if k in self.castelable:
AttributeError: 'BtchBoard' object has no attribute 'castelable'

show possible moves

When a player select a piece, the UI should show the list of possible moves.

Avatar upload

Provide a way to upload avatars (png, jpeg, resize everything to 200x200 px). It should return the URL of the newly created avatar.

Show taken pieces

You can currently not see the pieces that you have taken. While this is an interesting variant of the game, it's probably better to have the taken pieces shown in the default game.

resize avatars, fix integration with user model

Once #48 is accepted there'll still be an integration issue: it doesn't use avatar column in User. Should it?

There's also the 200x200 resizing and image verify missing, for that we need Pillow python module to process images.

Define REST API

Create a full definition of the REST API to be used for Battlechess

API to get all possible moves for a piece

  • Should only be available for ongoing games
  • Should only be accessible for both players of the game (auth via token)
  • Should take into account what the player can see and not see
    GET /games/{gameUUID}/moves/{starting position}

refactor game state retrival

/games/{gameUUID}/snap
/games/{gameUUID}/snap
/games/{gameUUID}/snap/{moveNum}

  • should only return visible state for one of the two player and error out for external peoples if the game is ongoing
  • should return full state if game is over

/games
/games/{gameuuid}

  • should not return snaps

post to /games improvements

Today someone posting a new game doesn't end-up being part of the game. This is odd.
Here is how I think it should work initially:

  • user posts a game and sends two parameters
    • If the game is public or not
    • The color he wants. If no color is given, a random one is affected right away

This way we don't end up with new games with 0 player in it and a player creating a game doesn't have to join it.

Server setup

Define what technology to use on server side (flask, django, node.js, ...) Ideally in python because of the existing codebase.

remove games/whites/blacks from users queries

Today a query on /users returns a list of users that includes too much information. We should remove the lists games, whites and blacks

[
  {
    "username": "string",
    "full_name": "string",
    "email": "string",
    "id": 0,
    "status": "string",
    "games": [],
    "whites": [],
    "blacks": []
  }
]

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.