classes usage


I’m still investigating classes and typed this at some point

class ChessGamePlayerInfo(bpy.types.PropertyGroup) :
    name  = bpy.props.StringProperty()
    human = bpy.props.BoolProperty()
    moves = bpy.props.CollectionProperty(type=ChessGamePlayerMoves)
    <b>move  = {} #[] don't work list is the same for white/black :(</b>

class ChessGamePlayer(bpy.types.PropertyGroup) :
    white = bpy.props.PointerProperty(type=ChessGamePlayerInfo)
    black = bpy.props.PointerProperty(type=ChessGamePlayerInfo)

in order to have ‘api browsable’ values like :

chess = bpy.context.scene.chess['0']['king'] # or [0]['king'] with a list

my question (the bold line) is that and point on the same dictionnary… (but name, human or any other bpy.props properties will work fine, apart between b&w)… so it’s a bit stupid for my purpose.

[['e', '8']]

&gt;&gt;&gt;<b>white</b>.move['0']['king'] = 'of the hill'
'of the hill'

I could declare ChessGamePlayerInfo as a CollectionProperty but I’ll get['white'].moves['0'].king['black'].name

less pretty :slight_smile: also I only need two players… so I’d like to keep the first way…

any help comment or pointers welcome, thanks

I duplicated ChessGamePlayerInfo : ChessGameWhitePlayerInfo and ChessGameBlackPlayerInfo and the associated pointers.
is there a better way ?