Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Domain Modeling - Design Workflow: assign role #84

Open
kayac-chang opened this issue May 18, 2023 · 5 comments
Open

Domain Modeling - Design Workflow: assign role #84

kayac-chang opened this issue May 18, 2023 · 5 comments
Assignees
Labels
help wanted Extra attention is needed

Comments

@kayac-chang
Copy link
Collaborator

implement design of https://hackmd.io/KvV2Ou3HS9uN11OUpsAUzA?both#Workflow-assign-role

@kayac-chang kayac-chang added the help wanted Extra attention is needed label May 18, 2023
@JohnsonMao JohnsonMao self-assigned this May 28, 2023
@JohnsonMao
Copy link
Contributor

JohnsonMao commented May 29, 2023

Command

type AssignRoleCommand = {
    playerId: string;
    role: RoleCard;
}

Event

type AssignRoleEvent = {
    playerId: string;
    role: RoleCard;
}

Error

type AssignRoleError = EventSourceWriteError

Type

type AssignRole = (eventsource: EventSource, command: AssignRoleCommand) => ResultAsync<AssignRoleEvent, AssignRoleError>

Workflow

workflow: assign role
    input:
        event source
        assign role command
    output:
        async result of 
            ok -> player assign role event
            err -> assign role error
    step:
        append event to event source
            if error occured:
                return event source write error
            otherwise:
                return assign role event

@kayac-chang
Copy link
Collaborator Author

@JohnsonMao
could you also provide the type of assign role so we can make sure what type interface we have to follow.

@JohnsonMao
Copy link
Contributor

Due to the adjustments in the turn start process, the "assign role" function has been modified as follows.

@kayac-chang
Copy link
Collaborator Author

type AssignRole = (eventsource: EventSource, command: AssignRoleCommand) => ResultAsync<AssignRoleEvent, AssignRoleError>

@JohnsonMao
Copy link
Contributor

To ensure logical validation and further completion, we would need the following additional functions:

  • Validate player count
  • Calculate role card count by player count
  • Randomly assign role cards for all players

Error

type NotEnoughPlayersError = Error & {
    name: 'NotEnoughPlayersError'
    message: 'Not enough players'
}

type ExceededPlayerCountError = Error & {
    name: 'ExceededPlayerCountError'
    message: 'Exceeded player count'
}

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
help wanted Extra attention is needed
Projects
None yet
Development

No branches or pull requests

2 participants