Ejemplo n.º 1
0
    private void increaseFatigue(CrewModel theCrew)
    {
        // check to see if we are maxxed out. If we are,
        // change the first found fatigue to INJURY
        // otherwise, if there are not fatigues, we
        // convert to injury.

        if (theCrew.healthTrack.Count == theCrew.healthTrackSize)
        {
            // convert a fatigue to injury
            bool found = false;
            for (int index = 0; index <= theCrew.healthTrack.Count - 1; index++)
            {
                if ((int)theCrew.healthTrack[index] == (int)ecrewHealthTrackDamage.fatigue && found == false)
                {
                    theCrew.healthTrack[index] = ecrewHealthTrackDamage.fitness;
                    found = true;
                    Debug.Log("Fatigue turned to injury!");
                }
            }

            // if not found, cause regular damage
            if (!found)
            {
                decreaseFitness(theCrew);
            }
        }
        else
        {
            // just add a fatigue
            Debug.Log("Fatigue increased");
            theCrew.healthTrack.Add(ecrewHealthTrackDamage.fatigue);
        }
    }
Ejemplo n.º 2
0
    private void decreaseFitness(CrewModel theCrew)
    {
        if (theCrew.healthTrack.Count == theCrew.healthTrackSize)
        {
            bool found = false;
            for (int index = 0; index <= theCrew.healthTrack.Count - 1; index++)
            {
                if ((int)theCrew.healthTrack[index] == (int)ecrewHealthTrackDamage.fatigue && found == false)
                {
                    theCrew.healthTrack[index] = ecrewHealthTrackDamage.fitness;
                    found = true;
                }
            }

            if (found == false)
            {
                // really hurt someone!
                Debug.Log("Injure the crap out of someone");
            }
        }
        else
        {
            theCrew.healthTrack.Add(ecrewHealthTrackDamage.fitness);
        }
    }
Ejemplo n.º 3
0
    private void makeProgress(CrewModel theCrew, OverlandTileModel tileModel, ArrayList dice)
    {
        if (theCrew.halted == false)
        {
            theCrew.progress++;
        }

        Debug.Log("Make progress");
    }
Ejemplo n.º 4
0
    private void backtrack(CrewModel theCrew, OverlandTileModel tileModel)
    {
        // reduce progress made and increases time (time increase is baked into the rule above)
        theCrew.progress--;
        if (theCrew.progress < 0)
        {
            theCrew.progress = 0;
        }

        Debug.Log("Lose progress");
    }
        public bool delete(CrewModel o)
        {
            query    = "ProcDeleteCrew";
            dbParams = new SqlParameter[]
            {
                new SqlParameter("@id", o.idcrew)
            };

            isValid = config.eksekusiQuery(query, dbParams, false);

            return(isValid);
        }
Ejemplo n.º 6
0
        public static void Handle(Packet packet)
        {
            var checkTeamNamePacket = new CheckTeamNamePacket(packet);

            var nameTaken = CrewModel.CheckNameExists(GameServer.Instance.Database.Connection,
                                                      checkTeamNamePacket.TeamName);

            packet.Sender.Send(new CheckTeamNameAnswer()
            {
                Availability = !nameTaken,
                TeamName     = checkTeamNamePacket.TeamName
            }.CreatePacket());
        }
        public ActionResult EditCrew(string id, CrewModel obj)
        {
            if (ic.edit(obj))
            {
                ViewBag.Message = "Crew edit successfully";
            }
            else
            {
                ModelState.AddModelError("", "Saving a request does not save");
            }

            return(View(obj));
        }
Ejemplo n.º 8
0
 private void consumeProvisions(CrewModel theCrew)
 {
     if (theCrew.provisions == 0)
     {
         Debug.Log("No more food left, fatigue increased");
         increaseFatigue(theCrew);
     }
     else
     {
         Debug.Log("Om, nom, nom.");
         theCrew.provisions--;
     }
 }
        public bool save(CrewModel o)
        {
            query    = "ProcInsertCrew";
            dbParams = new SqlParameter[]
            {
                new SqlParameter("@name", o.name),
                new SqlParameter("@status", o.status),
                new SqlParameter("@airport", o.airport),
                new SqlParameter("@company", o.companyairways)
            };

            isValid = config.eksekusiQuery(query, dbParams, false);

            return(isValid);
        }
        public ActionResult CreateCrew()
        {
            if (SessionPersister.username != "")
            {
                var data  = ic.GetAllStatus();
                var model = new CrewModel();
                model.setStatus = ic.GetSelectListItems(data);

                return(View(model));
            }
            else
            {
                return(RedirectToAction("AccesDenied", "Home"));
            }
        }
        public ActionResult DeleteCrew(string id)
        {
            try
            {
                CrewModel obj = new CrewModel();
                obj.idcrew = id;

                ic.delete(obj);

                return(RedirectToAction("DashboardAdmin", "Home"));
            }
            catch
            {
                return(View());
            }
        }
Ejemplo n.º 12
0
 private void increaseFitness(CrewModel theCrew)
 {
     if (theCrew.healthTrack.Count > 0)
     {
         bool found = false;
         for (int index = 0; index <= theCrew.healthTrack.Count - 1; index++)
         {
             if ((int)theCrew.healthTrack[index] == (int)ecrewHealthTrackDamage.fitness && found == false)
             {
                 theCrew.healthTrack.RemoveAt(index);
                 found = true;
                 Debug.Log("Injury recovered");
             }
         }
     }
 }
        public ActionResult CreateCrew(CrewModel obj)
        {
            var data = ic.GetAllStatus();

            obj.setStatus = ic.GetSelectListItems(data);

            if (ic.save(obj))
            {
                return(RedirectToAction("CreateCrew", "Home"));
            }
            else
            {
                ModelState.AddModelError("", "Saving a request does not save");
            }

            return(View("CreateCrew", obj));
        }
Ejemplo n.º 14
0
    private void enforceTimeCosts(CrewModel theCrew, string effect)
    {
        int tc = timeCosts ["default"];

        if (timeCosts.ContainsKey(effect))
        {
            // add this time cost
            tc = timeCosts[effect];
        }

        theCrew.currentTimeSegment += tc;

        if (theCrew.currentTimeSegment > 9)
        {
            theCrew.currentTimeSegment = 0;
        }
    }
Ejemplo n.º 15
0
 private void decreaseFatigue(CrewModel theCrew)
 {
     if (theCrew.healthTrack.Count > 0)
     {
         bool found = false;
         for (int index = 0; index <= theCrew.healthTrack.Count - 1; index++)
         {
             if ((int)theCrew.healthTrack[index] == (int)ecrewHealthTrackDamage.fatigue && found == false)
             {
                 theCrew.healthTrack.RemoveAt(index);
                 found = true;
             }
         }
         if (found)
         {
             Debug.Log("Fatigue reduced");
         }
         else
         {
             Debug.Log("No fatigue to recover");
         }
     }
 }
Ejemplo n.º 16
0
    public void processAction(CrewModel theCrew, edieIcon theIcon, OverlandTileModel tileModel, ArrayList dice)
    {
        ArrayList currentEffects;

        // we pass in DICE because we may need to know what is on other faces later (like blades, etc)


        if (dieIconEffects.ContainsKey((int)theIcon))
        {
            currentEffects = dieIconEffects[(int)theIcon];
            foreach (string effect in currentEffects)
            {
                enforceTimeCosts(theCrew, effect);

                switch (effect)
                {
                case "none":
                    break;

                case "increaseFitness":
                    increaseFitness(theCrew);
                    break;

                case "bonus":
                    break;

                case "progress":
                    makeProgress(theCrew, tileModel, dice);
                    break;

                case "decreaseFatigue":
                    decreaseFatigue(theCrew);
                    break;

                case "disaster":
                    disaster(theCrew);
                    break;

                case "decreaseFitness":
                    decreaseFitness(theCrew);
                    break;

                case "consumeProvisions":
                    consumeProvisions(theCrew);
                    break;

                case "halt":
                    halt(theCrew);
                    break;

                case "backtrack":
                    backtrack(theCrew, tileModel);
                    break;

                case "timePasses":
                    timePasses(theCrew);
                    break;

                case "increaseFatigue":
                    increaseFatigue(theCrew);
                    break;

                default:
                    Debug.Log("fall through.");
                    break;
                }
            }
        }
    }
Ejemplo n.º 17
0
 private void disaster(CrewModel theCrew)
 {
     theCrew.disasters++;
     // code later to raise a disaster encounter
     Debug.Log(string.Format("Disaster! Total: {0}", theCrew.disasters));
 }
Ejemplo n.º 18
0
        public static void Handle(Packet packet)
        {
            if (packet.Sender.User == null)
            {
                packet.Sender.SendError("Session game information is abnormal. Please log-in again.");
                packet.Sender.KillConnection("User was not loaded.");
                return;
            }

            if (packet.Sender.User.ActiveCharacter == null)
            {
                packet.Sender.SendError("Session character information is abnormal. Please log-in again.");
                packet.Sender.KillConnection("Character was not loaded.");
                return;
            }

            var crew = new Crew();

            crew.Unserialize(packet.Reader);

            var cost      = GameServer.Instance.Config.Game.CrewCreationCost;
            var levelReq  = GameServer.Instance.Config.Game.CrewCreationMinLevel;
            var character = packet.Sender.User.ActiveCharacter;

            // Check if char already is in a crew
            if (character.Crew != null || character.CrewId != -1)
            {
                packet.Sender.SendError("You are already a member of a crew.");
                return;
            }

            // Check if the crew name really doesn't exist
            if (CrewModel.CheckNameExists(GameServer.Instance.Database.Connection, crew.Name))
            {
                packet.Sender.SendError("This crew name is already in use.");
                Log.Warning(
                    $"{packet.Sender.User.Username} suspected packet hacking. Tried to create a crew with a name that already is used!");
                return;
            }

            // Check if he has enough mito to "buy" the crew
            if (character.MitoMoney < cost && packet.Sender.User.Permission < UserPermission.Developer)
            {
                packet.Sender.SendError($"{cost} Mito is required to make a crew.");
                return;
            }

            // Check if he has the level required (Ignore if he's dev or higher.)
            if (character.Level < levelReq && packet.Sender.User.Permission < UserPermission.Developer)
            {
                packet.Sender.SendError($"Only users at Level {levelReq} or higher can make a crew.");
                return;
            }

            crew.LeaderName = packet.Sender.User.ActiveCharacter.Name;
            crew.LeaderId   = (long)packet.Sender.User.ActiveCharacterId;
            crew.OwnerName  = packet.Sender.User.ActiveCharacter.Name;
            crew.OwnerId    = (long)packet.Sender.User.ActiveCharacterId;
            crew.CreateDate = (uint)DateTimeOffset.Now.ToUnixTimeMilliseconds();
            crew.MemberCnt  = 1;
            crew.Point      = 0;

            if (!CrewModel.Create(GameServer.Instance.Database.Connection, ref crew))
            {
                packet.Sender.SendError("Failed to create crew. Please try again later!");
                return;
            }

            packet.Sender.User.ActiveCharacter.CrewId     = crew.Id;
            packet.Sender.User.ActiveCharacter.CrewRank   = 1; // Crew Master
            packet.Sender.User.ActiveCharacter.Crew       = crew;
            packet.Sender.User.ActiveCharacter.MitoMoney -= cost;
            if (!CharacterModel.Update(GameServer.Instance.Database.Connection, packet.Sender.User.ActiveCharacter))
            {
                packet.Sender.SendError("Failed to set your crew!");
                return;
            }

            var ack = new Packet(Packets.CreateTeamAck);

            ack.Writer.Write(1);                                            // Result? 1=Correct, 2=Wrong? Does this even matter?
            ack.Writer.Write(crew);
            ack.Writer.Write((ushort)0);                                    // Session Age?
            ack.Writer.Write(packet.Sender.User.ActiveCharacter.MitoMoney); // Result money..
            packet.Sender.Send(ack);

            // sub_546B80 => 680

            /*
             * int m_Result;
             * XiStrTeamInfo m_TeamInfo;
             * unsigned __int16 m_Age;
             * __int64 m_ResultMoney;
             */
        }
Ejemplo n.º 19
0
    //
    public void processSeries(CrewModel theCrew, ArrayList dice, OverlandTileModel tileModel)
    {
        foreach (DieView die in dice)
        {
            // get an array of effects on the current side
            ArrayList results = die.model.iconsOnCurrentSide();
            foreach (edieIcon icon in results)
            {
                processAction(theCrew, icon, tileModel, dice);
            }
        }

        int finalIndex = 0;
        int startIndex = tileModel.currentNode;

        bool movementHalted = false;



        // process progress total
        if (theCrew.progress > 0)
        {
            for (int index = 0; index <= theCrew.progress; index++)
            {
                if (!movementHalted)
                {
                    OverlandWaypointModel wap = (OverlandWaypointModel)tileModel.waypoints[index + tileModel.currentNode];

                    //OverlandWaypointModel startNode = (OverlandWaypointModel)tileModel.waypoints[startIndex];
                    // verify we have the prerequisite for the next

                    // if we LAND on a camp, we're done.
                    if (wap.waypointType == ewaypointType.waypointCamp && index + tileModel.currentNode != startIndex)
                    {
                        movementHalted = true;
                        // display further waypoints
                        revealWaypointsAfterCamp(index + tileModel.currentNode, tileModel);
                    }

                    // if we LAND on an encounter, we're done.
                    if (wap.waypointType == ewaypointType.waypointEncounter && index + tileModel.currentNode != startIndex)
                    {
                        movementHalted = true;
                    }

                    // if we LAND on an icon that we don't have in hand, we're done
                    if (wap.waypointType == ewaypointType.waypointOptionalEncounter && index + tileModel.currentNode != startIndex)
                    {
                        //movementHalted = true;
                    }

                    // icon waypoint
                    if (wap.waypointType == ewaypointType.waypointIcon && index + tileModel.currentNode != startIndex && wap.iconRequirement != ewaypointType.waypointBoots)
                    {
                        // check to see if we have one
                        if (!hasRequiredIcon(dice, wap.iconRequirement))
                        {
                            movementHalted = true;
                        }
                    }

                    // if we LAND on the final, we're done


                    finalIndex = index + tileModel.currentNode;

                    // check the previous waypoint
                    if (index + tileModel.currentNode - 1 >= 0)
                    {
                        OverlandWaypointModel bak = (OverlandWaypointModel)tileModel.waypoints[index + tileModel.currentNode - 1];
                        bak.passed = true;
                    }
                    wap.reached = true;
                }
            }
        }

        tileModel.currentNode = finalIndex;
        // reset crew progress
        theCrew.progress = 0;
    }
Ejemplo n.º 20
0
 private void bonus(CrewModel theCrew)
 {
     // this probably shouldn't do anything in overland map
     Debug.Log("'bonus' has no effect in overland");
 }
Ejemplo n.º 21
0
 private void halt(CrewModel theCrew)
 {
     theCrew.halted = true;
     Debug.Log("Crew halted");
 }
Ejemplo n.º 22
0
 private void timePasses(CrewModel theCrew)
 {
     // nothing special happens here since the actual time pass is paid for in time...? wut?
     Debug.Log("Time passes");
 }