Puzzle.cs :  » Game » SokoSolve-Sokoban » SokoSolve » Core » Model » C# / CSharp Open Source

Home
C# / CSharp Open Source
1.2.6.4 mono .net core
2.2.6.4 mono core
3.Aspect Oriented Frameworks
4.Bloggers
5.Build Systems
6.Business Application
7.Charting Reporting Tools
8.Chat Servers
9.Code Coverage Tools
10.Content Management Systems CMS
11.CRM ERP
12.Database
13.Development
14.Email
15.Forum
16.Game
17.GIS
18.GUI
19.IDEs
20.Installers Generators
21.Inversion of Control Dependency Injection
22.Issue Tracking
23.Logging Tools
24.Message
25.Mobile
26.Network Clients
27.Network Servers
28.Office
29.PDF
30.Persistence Frameworks
31.Portals
32.Profilers
33.Project Management
34.RSS RDF
35.Rule Engines
36.Script
37.Search Engines
38.Sound Audio
39.Source Control
40.SQL Clients
41.Template Engines
42.Testing
43.UML
44.Web Frameworks
45.Web Service
46.Web Testing
47.Wiki Engines
48.Windows Presentation Foundation
49.Workflows
50.XML Parsers
C# / C Sharp
C# / C Sharp by API
C# / CSharp Tutorial
C# / CSharp Open Source » Game » SokoSolve Sokoban 
SokoSolve Sokoban » SokoSolve » Core » Model » Puzzle.cs
using System;
using System.Collections.Generic;
using System.Text;
using System.Xml;
using SokoSolve.Core.Model.Analysis;
using SokoSolve.Core.Model.DataModel;

namespace SokoSolve.Core.Model{
    /// <summary>
    /// This class extendes the basic SokobanMap and adds additional 'management' information.
    /// </summary>
    /// <remarks>
    /// Like SokobanMap, no game logic is included here.
    /// </remarks>
    public class Puzzle 
    {
      private List<PuzzleMap> maps;
    private GenericDescription details;
    private int order; 
    private Category category;
      private string rating;
        private string puzzleID;
        private Library library; // simple back reference

        /// <summary>
        /// Default Constructor
        /// </summary>
        /// <param name="myLibrary"></param>
      public Puzzle(Library myLibrary)
      {
        maps = new List<PuzzleMap>();
        details = new GenericDescription();
          library = myLibrary;
      }

        /// <summary>
        /// Use Library.IDProvider to set
        /// </summary>
        public string PuzzleID
        {
            get { return puzzleID; }
            set { puzzleID = value; }
        }

       /// <summary>
       /// Simple ownershio back-ref
       /// </summary>
        public Library Library
        {
            get { return library; }
            set { library = value;  }
        }

        /// <summary>
        /// Member category
        /// </summary>
        public Category Category
    {
      get { return category; }
      set { category = value; }
    }

        /// <summary>
        /// Order (independant of category)
        /// </summary>
      public int Order
      {
        get { return order; }
        set { order = value; }
      }

        /// <summary>
        /// List of all maps in the puzzle
        /// </summary>
      public List<PuzzleMap> Maps
      {
        get { return maps; }
        set { maps = value; }
      }

        /// <summary>
        /// List of alternatives
        /// </summary>
        public List<PuzzleMap> Alternatives
        {
            get
            {
                if (!HasAlternatives) return null;
                List<PuzzleMap> alt = new List<PuzzleMap>(maps);
                alt.RemoveAt(0);
                return alt;
            }
        }

        /// <summary>
        /// Puzzle generic details, name, author etc.
        /// </summary>
      public GenericDescription Details
      {
        get { return details; }
        set { details = value; }
      }

        /// <summary>
        /// Rating String
        /// </summary>
      public string Rating
      {
        get { return rating; }
        set { rating = value; }
      }

        /// <summary>
        /// Calculate an automated rating for the puzzle
        /// </summary>
        public double AutomatedRating
        {
            get
            {
                if (MasterMap != null)
                {
                    return PuzzleAnalysis.CalcRating(MasterMap.Map);
                }
                return 0;
            }
        }

        /// <summary>
        /// Master/Primary map for the puzzle
        /// </summary>
        public PuzzleMap MasterMap
        {
            get
            {
                if (maps != null && maps.Count > 0) return maps[0];
                return null;
            }
            set
            {
                if (maps.Count ==0 && value != null)
                {
                    maps.Add(value);
                    return;
                }

                if (maps.Count > 0)
                {
                    maps[0] = value;
                }
            }
        }

        /// <summary>
        /// Are there alternative puzzle maps?
        /// </summary>
        public bool HasAlternatives
        {
            get
            {
                return maps.Count > 1;
            }
        }

        /// <summary>
        /// Debug string helper
        /// </summary>
        /// <returns></returns>
        public override string ToString()
        {
            return string.Format("{0} {1}", puzzleID, details);
        }

        public GenericDescription GetDetails()
        {
            return GenericDescription.Combine(details, Library.GetDetails());
        }
    }
}
www.java2v.com | Contact Us
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.