Example #1
0
        public ChestItemViewModel Get(string playerName, Guid chestIdentifier)
        {
            // I want to return an item with a deterministic id from the chest
            // so that each player gets the same item, and a returning player
            // cannot loot more than one item from the chest.
            // Different chests will drop different items depending on their id.

            var chestHashCode = chestIdentifier.GetHashCode();
            var lootItem      = _lootTable.Roll(chestHashCode);
            var vm            = new ChestItemViewModel(
                string.Concat(chestHashCode, lootItem.Identifier), lootItem.Name);

            _logger.Log(string.Format(
                            "Player: {0}, Received: {1} {2}", playerName, vm.Identifier, vm.Name));

            return(vm);
        }