Skip to content

Simple library built over Photon Networking to ease creating bots for AoTTG game by Feng Lee

Notifications You must be signed in to change notification settings

aelariane/AottgBotLib

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

3 Commits
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

AottgBotLib

Simple tiny library to ease creating "bots" for indie game AoTTG by Feng Lee

Basically, this library is just a layer built on Photon Network C# libraries to simlify interations for specified game.

Usage example

using System;
using AottgBotLib;
using AottgBotLib.Handlers;
using Photon.Realtime;

class Program
{
    public static void Main(String[] args)
    {

        var client = new BotClient("BotName"); //Creating client
        client.Region = PhotonRegion.Europe; //Set region

        //Adding Chat support
        client.RPCHandler.AddChatCallback((id, sender, content) =>
        {
            sender = sender.RemoveAll(); //Removes all color codes
            content = content.RemoveAll(); //Removes all color codes
            Console.WriteLine($"[{id}] {sender}: {content}");
        };

        await client.ConnectToMasterAsync(); //Connecting to region
        
        RoomInfo roomToGetInto = null;
        foreach (RoomInfo room in client.RoomList)
        {
            if (room.Name.Contains("roomNameYouWantToJoin"))
            {
                roomToGetInto = room;
                break;
            }
        }
        if(roomToGetInto == null)
        {
            Environment.Exit(0);
        }
        await client.JoinRoomAsync(roomToGetInto);
        //Voila. You have connected to room you want and now can read what happens there
        
        //Leaving this here to keep console open
        while(true)
        {
            string line = Console.WriteLine();
            if(line == "exit") //Typing exit to close console
            {
                Environment.Exit(0);
            }
            else
            {
                //Otherwise, what you printed will be sent to all players in room
                client.SendChatMessage(line);
            }
        }
    }
}

Build

IDE with C# 8.0 support
.NET Core 3.1

About

Simple library built over Photon Networking to ease creating bots for AoTTG game by Feng Lee

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages