dfinity / ICRC

Repository to ICRC proposals
Apache License 2.0
29 stars 5 forks source link

ICRC-15: General Game stats standard #15

Open CapuzR opened 1 year ago

CapuzR commented 1 year ago

Context

The proposed ICRC-14 Game General Stats standard is important because it establishes a common format for games to expose their main game stats and player stats. This format can be used by various ICP games, tools, and gamers to query gaming data in a standardized way, thereby improving interoperability between games and enabling collaboration between multiple projects.

Data details

Summary

Minimal set of types and methods for games to expose their main game stats and players stats to boost collaboration and side tooling.

Introduction

This proposal describes the minimal set of types and methods that will help games to have standard stats for their main stats and player stats. We hope that this will boost ICP games interoperability and thrive the collaborations between multiple projects.

Goals

References

icrc14_get_game_stats

type StatsRequest = variant {
    StartDate : Int;
    EndDate : Int;
};

type Stats = record {
    active_players : Nat;
    unique_players : Nat;
    peak_concurrent_players : Nat;
    hours_played : Nat;
    cycles_burned : Nat;
    session_time_average : Nat;
    extras : vec {Property};
};

type RangeRequested = variant {
    StartDate : Int;
    EndDate : Int;
};

type Property = record {name : text; value : Value};

type Value = variant {
    Array : vec {Value};
    Principal : principal;
    Class : vec {Property};
    Option : opt Value;
    Bytes : vec {Nat8};

    Nat : nat;
    Nat8 : nat8;
    Nat16 : nat16;
    Nat32 : nat32;
    Nat64 : nat64;

    Int : int;
    Int8 : int8;
    Int16 : int16;
    Int32 : int32;
    Int64 : int64;

    Blob : blob;
    Bool : bool;
    Text : text;
    Float : float64;
};

service : {
icrc14_get_game_stats: (StatsRequest, ?RangeRequested ) -> (Stats);
}

icrc14_get_gamer_stats

type Identity = variant {
    Principal : principal;
};

type GamerStatsResults = variant {
    Ok : GamerStats;
    Err : opt GamerStatsError;  
};

type GamerStats = record {
    hours_played : Nat;
    session_time_average : Nat;
    extras : vec {Property};
};

type GamerStatsError = variant {
    NotAuthorized: record { reason: text };
};

service : {
    icrc14_get_gamer_stats: (Identity, ?RangeRequested ) -> (GamerStatsResults);
}

Complementary standards

There should probably be a standard to manage gamer data authorization and multiple standards to manage genre specific stats.

Hope to receive a lot of ideas and contributions to go forward with this standard.

CapuzR commented 1 year ago

Thanks for the feedback on the forum Hazel

Optional to support backwards compatibility in older clients

I have done some tests and I think Andrea’s feedback applies for GamerStatsError (Already updated) but my tests allows me to add identity variants without breaking frontends/otherCanis.

Here’s my basic test on motoko playground

Here’s a test using ICRC-11’s AuthRequest on motoko playground

In both of them, you can remove commented Text variant and check what I mean. Maybe I’m missing something, please let me know.

vec Property

Agreed and already updated!! Love to use a vec record and not a vec tuple that is usually a pain on frontends imo. DAB uses vec tuple for details, maybe we could talk/suggest Funded to change this to vec record, do you see any advantage on vec tuple approach?

CapuzR commented 1 year ago

Thanks a lot for taking the time to collab on this iBardak (Answer to forum post)

I want to clarify, this is not a token standard, these are just types and methods to be added on the main game canister if the game supports the standard.

The idea is to have an standard as simple as possible here (These are Game Stats). In Stats record you can see stats that every game normally have (I think):

type Stats = record {
    active_players : Nat;
    unique_players : Nat;
    peak_concurrent_players : Nat;
    hours_played : Nat;
    cycles_burned : Nat;
    session_time_average : Nat;
    extras : vec {Property};
};

and for Players is the same, I think these stats applies for every game:

type GamerStats = record {
    hours_played : Nat;
    session_time_average : Nat;
    extras : vec {Property};
};

I would love if you can give us your thoughts on this stats, if you consider that they are important enough to be on the basic standard and what other do you think that applies for all games.

Of course there are a lot of stats that varies between projects and this isn't by any means a restriction to use whatever stats a game wants to manage.

If we agree and use this standard, all the games on the IC can interoperate -with stats- easily based on that, and it will be super easy for additional tools (Internal and external to the IC) to map games and stats on the IC Game Ecosystem and give additional benefits to everyone.

After this basic standard we can work in by genre specific stats standard to complement this one (this will not be a restriction for games to use others than the ones on the standard though).

iBardak2020 commented 1 year ago

is there a ready-made implementation of this functionality on motoko? Starting from recording, ending with storing and issuing information

CapuzR commented 1 year ago

is there a ready-made implementation of this functionality on motoko? Starting from recording, ending with storing and issuing information

Not yet. I'm planning to implement an initial version soon to Elementum's game: Bounty Rush.

But in parallel to implementation I would really love to have a solid standard. Some doubts we have:

The stats we presented should be present in all games? What stat did I miss that could be present in all games? Should we manage authorization for players to decide what principal can check their stats? Should that be on this standard or in another that extends this one? I think this should be manage in a second standard to avoid limiting devs as much as possible in order to be a useful standard for any case. gamer stats or player stats? I would love to see an specific use of Value and vec property as a "good practice" throughout all the ICRC standards. (See ICRC-16 - CandyShared - Standardizing Unstructured Data Interoperability - #4 by skilesare) Best way to represent/manage dates on the standard.

SuddenlyHazel commented 1 year ago

Quick comment - can we update this to be ICRC-15 -> https://github.com/dfinity/ICRC/issues/15

iBardak2020 commented 1 year ago

Don't blow your head off. No one will be able to predict all possible options in the future. Just keep all the important statistics in the player's account. And let external resources can read these statistics. If you use NFT as an access key to the game account, then you can easily manage the game attributes without breaking the structure of your NFTs

CapuzR commented 1 year ago

Quick comment - can we update this to be ICRC-15 -> #15

I think Issue #14 is kind of lost. So that implies that we won't have ICRC-14?

What if people start filling issues that doesn't relate with the proposal of an ICRC?

For me is not a problem, just curious.

@SuddenlyHazel @benjizhai