Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 7784373
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 1, 20262026-06-01T20:05:06+00:00 2026-06-01T20:05:06+00:00

For my first post I’ve got a tricky question. I’m past walking through tutorials

  • 0

For my first post I’ve got a tricky question.

I’m past walking through tutorials but not far enough to join the Open Source Community.

Thanks to this Question I’m trying to create a program that tracks combinations used in Alchemy Games (Generally on a mobile phone etc)

I’ve got the following classes

  • Class Game contains properties for Elements and Combinations
  • Class Elements Inherits List(Of Element)
  • Class Combinations Inherits List(Of Combination)
  • Class Element
  • Class Combination

Combination contains Element 1 and Element 2 and List(Of Element) for the results

My Question:

Using Game.Elements how can I add a readonly property for combinations of that element.
i.e.

Assuming Elements has

  • Fire
  • Earth
  • Water
  • Air
  • Energy

And Combinations has

  • Fire + Earth = Energy
  • Earth + Air = Mud

I want

Game.Elements(“Energy”).Combinations to return a Combinations containing the 1 match.

  • Fire + Earth = Energy

So far I can’t seem to access the Combinations through the Game class

I am extremely open to any suggestions or advice

My Complete code so far is

Option Explicit On


'TODO: Add classes for Combinations
'TODO: Edit Elements class for Various filters (Filter by Category, Generation etc)

Public Class Game

    Private pElements As Elements
    Private pOptions As Options


    Public Property Options() As Options
        Get
            Return pOptions
        End Get
        Set(ByVal value As Options)
            pOptions = value
        End Set
    End Property

    Public Property Elements() As Elements
        Get
            Return pElements
        End Get
        Set(ByVal value As Elements)
            pElements = value
        End Set
    End Property

    Public Sub New()
        Me.Elements = New Elements()
        Me.Options = New Options()
    End Sub

    Public Sub New(ByVal TotalElements As Long, _
                   Optional ByVal TotalCategories As Long = 1, _
                   Optional ByVal Categories As Boolean = False, _
                   Optional ByVal Terminated As Boolean = False, _
                   Optional ByVal SelfCombination As Boolean = True, _
                   Optional ByVal ReverseCombination As Boolean = False)
        Me.Elements = New Elements()
        Me.Options = New Options(TotalElements, _
                                 TotalCategories, _
                                 Categories, _
                                 Terminated, _
                                 SelfCombination, _
                                 ReverseCombination)
    End Sub


End Class

#Region "Combinations"

Public Class Combinations
    Inherits List(Of Combination)
    Implements IEnumerable(Of Combination)

End Class

Public Class Combination

    Private pElements As List(Of Element)
    Private pResult As List(Of Element)


    Public Property Elements() As List(Of Element)
        Get
            Return pElements
        End Get
        Set(ByVal value As List(Of Element))
            pElements = value
        End Set
    End Property

    Public Property Result() As List(Of Element)
        Get
            Return pResult
        End Get
        Set(ByVal value As List(Of Element))
            pResult = value
        End Set
    End Property


End Class

#End Region

#Region "Elements"

Public Class Elements
    Inherits List(Of Element)
    Implements System.Collections.Generic.IComparer(Of Element)
    Implements IEnumerable(Of Element)


    Public Function Compare(ByVal e1 As Element, ByVal e2 As Element) As Integer Implements IComparer(Of Element).Compare
#If CONFIG = "Debug" Then
        Debug.WriteLine("{0} - {1}", e1.Name, e2.Name)
#End If
        Select Case e1.Generation
            Case Is = e2.Generation
                Select Case e1.Category.Name
                    Case Is = e2.Category.Name
                        Select Case e1.Name
                            Case Is = e2.Name
                                Return 0
                            Case Is > e2.Name
                                Return 1
                            Case Else '< e2.Name
                                Return -1
                        End Select
                    Case Is > e2.Category.Name
                        Return 1
                    Case Else '< e2.Category
                        Return -1
                End Select
            Case Is > e2.Generation
                Return 1
            Case Else '< e2.Generation
                Return -1
        End Select
    End Function

    Default Public Overloads ReadOnly Property Item(ByVal Name As String) As Element
        Get
            Return Me.Where(Function(k As Element) k.Name = Name).ElementAt(0)
        End Get
    End Property


End Class

Public Class Element
    Implements System.IComparable(Of Element)




    Public Name As String
    Public Category As Category
    Public Generation As Integer
    Public Terminal As Boolean

    Public Sub New()
        With Me
            .Name = "Blank"
            .Category = New Category()
            .Generation = 0
            .Terminal = False
        End With
    End Sub

    Public Sub New(ByVal Name As String, Optional ByVal Category As String = "N/A", Optional ByVal Generation As Long = 0, Optional ByVal Terminal As Boolean = False)
        With Me
            .Name = Name
            .Category = New Category(Category)
            .Generation = Generation
            .Terminal = Terminal
        End With
    End Sub

    Public Shared Operator =(ByVal e1 As Element, ByVal e2 As Element) As Boolean
        Return (e1.Category.Name = e2.Category.Name And _
               e1.Name = e2.Name And _
               e1.Generation = e2.Generation And _
               e1.Terminal = e2.Terminal)
    End Operator
    Public Shared Operator <>(ByVal e1 As Element, ByVal e2 As Element) As Boolean
        Return Not e1 = e2
    End Operator
    Public Shared Operator >(ByVal e1 As Element, ByVal e2 As Element) As Boolean
        'Generation
        'Category
        'Name
        Select Case e1.Generation
            Case Is = e2.Generation
                Select Case e1.Category.Name
                    Case Is = e2.Category.Name
                        Select Case e1.Name
                            Case Is = e2.Name
                                Return False
                            Case Is > e2.Name
                                Return True
                            Case Else '< e2.Name
                                Return False
                        End Select
                    Case Is > e2.Category.Name
                        Return True
                    Case Else '< e2.Category
                        Return False
                End Select
            Case Is > e2.Generation
                Return True
            Case Else '< e2.Generation
                Return False
        End Select
    End Operator
    Public Shared Operator <(ByVal e1 As Element, ByVal e2 As Element) As Boolean
        Return Not (e1 >= e2)
    End Operator
    Public Shared Operator >=(ByVal e1 As Element, ByVal e2 As Element) As Boolean
        Return (e1 = e2 OrElse e1 > e2)
    End Operator
    Public Shared Operator <=(ByVal e1 As Element, ByVal e2 As Element) As Boolean
        Return (e1 = e2 OrElse e1 < e2)
    End Operator

    Public Function CompareTo(ByVal e1 As Element) As Integer Implements IComparable(Of Element).CompareTo
        Select Case Me.Generation
            Case Is = e1.Generation
                Select Case Me.Category.Name
                    Case Is = e1.Category.Name
                        Select Case Me.Name
                            Case Is = e1.Name
                                Return 0
                            Case Is > e1.Name
                                Return 1
                            Case Else '< e2.Name
                                Return -1
                        End Select
                    Case Is > e1.Category.Name
                        Return 1
                    Case Else '< e2.Category
                        Return -1
                End Select
            Case Is > e1.Generation
                Return 1
            Case Else '< e2.Generation
                Return -1
        End Select
    End Function
    Public Overrides Function ToString() As String
        With Me
            Return .WL("{0} - {1} - {2} - {3}", .Name, .Category.Name, .Generation, Terminal)
        End With
    End Function
    Private Function WL(ByVal value As String, ByVal ParamArray args As String()) As String
        For i = LBound(args) To UBound(args)
            value = value.Replace("{" & i & "}", args(i))
        Next
        Return value
    End Function
End Class

Public Class ElementComparer
    Implements System.Collections.Generic.IComparer(Of Element)
    Public Function Compare(ByVal e1 As Element, ByVal e2 As Element) As Integer Implements IComparer(Of Alchemy.Element).Compare

        Select Case e1.Generation
            Case Is = e2.Generation
                Select Case e1.Category.Name
                    Case Is = e2.Category.Name
                        Select Case e1.Name
                            Case Is = e2.Name
                                Return 0
                            Case Is > e2.Name
                                Return 1
                            Case Else '< e2.Name
                                Return -1
                        End Select
                    Case Is > e2.Category.Name
                        Return 1
                    Case Else '< e2.Category
                        Return -1
                End Select
            Case Is > e2.Generation
                Return 1
            Case Else '< e2.Generation
                Return -1
        End Select
    End Function
End Class

#End Region

Public Class Options

#Region "Properties"
    Private pAllowCategories As Boolean
    Private pAllowTerminatedElements As Boolean
    Private pAllowSelfCombination As Boolean
    Private pAllowReverseCombination As Boolean
    Private pTotalElements As Long
    Private pTotalCategories As Long
#End Region

#Region "Property Set"
    Public Property AllowCategories() As Boolean
        Get
            Return pAllowCategories
        End Get
        Set(ByVal value As Boolean)
            pAllowCategories = value
        End Set
    End Property
    Public Property AllowTerminatedElements() As Boolean
        Get
            Return pAllowTerminatedElements
        End Get
        Set(ByVal value As Boolean)
            pAllowTerminatedElements = value
        End Set
    End Property
    Public Property AllowSelfCombination() As Boolean
        Get
            Return pAllowSelfCombination
        End Get
        Set(ByVal value As Boolean)
            pAllowSelfCombination = value
        End Set
    End Property
    Public Property AllowReverseCombination() As Boolean
        Get
            Return pAllowReverseCombination
        End Get
        Set(ByVal value As Boolean)
            pAllowReverseCombination = value
        End Set
    End Property
    Public Property TotalElements() As Long
        Get
            Return pTotalElements
        End Get
        Set(ByVal value As Long)
            pTotalElements = value
        End Set
    End Property
    Public Property TotalCategories() As Long
        Get
            Return pTotalCategories
        End Get
        Set(ByVal value As Long)
            pTotalCategories = value
        End Set
    End Property
#End Region

#Region "Methods"
    Public Sub New(ByVal TotalElements As Long, _
                   Optional ByVal TotalCategories As Long = 1, _
                   Optional ByVal Categories As Boolean = False, _
                   Optional ByVal Terminated As Boolean = False, _
                   Optional ByVal SelfCombination As Boolean = True, _
                   Optional ByVal ReverseCombination As Boolean = False)
        With Me
            .TotalCategories = TotalCategories
            .TotalElements = TotalElements
            .AllowCategories = Categories
            .AllowTerminatedElements = Terminated
            .AllowSelfCombination = SelfCombination
            .AllowReverseCombination = ReverseCombination
        End With
    End Sub

    Public Sub New()
        With Me
            .TotalCategories = 1
            .TotalElements = 1
            .AllowCategories = False
            .AllowTerminatedElements = False
            .AllowSelfCombination = True
            .AllowReverseCombination = False
        End With
    End Sub

#End Region

End Class

Public Class Category

    Private pName As String
    Private pID As UInteger

    Public Property Name() As String
        Get
            Return pName
        End Get
        Set(ByVal value As String)
            pName = value
        End Set
    End Property

    Public Property ID() As UInteger
        Get
            Return pID
        End Get
        Set(ByVal value As UInteger)
            pID = value
        End Set
    End Property

    Public Sub New()
        Me.Name = "N/A"
        Me.ID = 0
    End Sub

    Public Sub New(ByVal Name As String, Optional ByVal ID As UInteger = 0)
        Me.Name = Name
        Me.ID = ID
    End Sub
End Class
  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-01T20:05:07+00:00Added an answer on June 1, 2026 at 8:05 pm

    I’ve found a solution.

    Public Class cGame
        Public Elements as cElements
        Public Sub New()
            cElements.Parent = Me
        End Sub
    End Class
    Public Class cElements
        Protected Friend Shared Parent As cGame
    End Class
    Public Class cCombinations
        Protected Friend Shared Parent As cGame
    End Class
    

    I then reference it with

    MyGame.Elements.Parent
    

    Which then can branch out into the Combinations like

    MyGame.Elements.Parent.Combinations
    

    and it will always reference the same data.

    🙂

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

(my first post was not clear and confusing so I've edited the question) I
my first post here. I'm not new to JQuery, but I find complex coding
first post here, and probably an easy one. I've got the code from Processing's
first post here, I come in peace :) I've searched but can't quite find
my first post here. I am not much of a programmer, I can tailor
First post, but long time browser :) So here's my problem: Basically I have
First post here, so I hope it is detailed enough. While developing an Iphone
first post, so play nice! I have a fairly basic question about Python dictionaries.
this is my first post here. I'm using an existing Flash widget but would
This is my first post on stackoverflow, I hope one of many! My question

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.