Archived
1

YAML files for rarely changed data. New weapon stats.

This commit is contained in:
Vladimir Hodakov 2018-04-30 19:46:28 +04:00
parent 87214a9973
commit b1975a161c
14 changed files with 413 additions and 42 deletions

18
b0x.yaml Normal file
View File

@ -0,0 +1,18 @@
pkg: static
dest: "./static/"
fmt: true
updater:
enabled: false
compression:
compress: false
clean: false
output: "ab0x.go"
unexporTed: false
spread: false
lcf: true
debug: false
custom:
- files:
- "data/*.yml"
base: "data/"
prefix: ""

48
data/elements.yml Normal file
View File

@ -0,0 +1,48 @@
- id: 1
symbol: "👊"
name: "Боевой"
league_id: 1
- id: 2
symbol: "🌀"
name: "Летающий"
league_id: 1
- id: 3
symbol: "💀"
name: "Ядовитый"
league_id: 1
- id: 4
symbol: "🗿"
name: "Каменный"
league_id: 1
- id: 5
symbol: "🔥"
name: "Огненный"
league_id: 2
- id: 6
symbol: "⚡"
name: "Электрический"
league_id: 2
- id: 7
symbol: "💧"
name: "Водяной"
league_id: 2
- id: 8
symbol: "🍀"
name: "Травяной"
league_id: 2
- id: 9
symbol: "💩"
name: "Отважный"
league_id: 3
- id: 10
symbol: "👁"
name: "Психический"
league_id: 3
- id: 11
symbol: "👿"
name: "Темный"
league_id: 3
- id: 12
symbol: "⌛"
name: "Времени"
league_id: 3

9
data/leagues.yml Normal file
View File

@ -0,0 +1,9 @@
- id: 1
symbol: 🈸
name: "ИНСТИНКТ"
- id: 2
symbol: 🈳
name: "МИСТИКА"
- id: 3
symbol: 🈵
name: "ОТВАГА"

18
data/locations.yml Normal file
View File

@ -0,0 +1,18 @@
- id: 1
symbol: "🌲"
name: "Лес"
- id: 2
symbol: "⛰"
name: "Горы"
- id: 3
symbol: "🚣"
name: "Озеро"
- id: 4
symbol: "🏙"
name: "Город"
- id: 5
symbol: "🏛"
name: "Катакомбы"
- id: 6
symbol: "⛪️"
name: "Кладбище"

44
data/weapons.yml Normal file
View File

@ -0,0 +1,44 @@
- id: 1
name: "Бита"
power: 3
price: 5
- id: 2
name: "Стальная бита"
power: 30
price: 2700
- id: 3
name: "Чугунная бита"
power: 60
price: 5400
- id: 4
name: "Титановая бита"
power: 100
price: 9000
- id: 5
name: "Алмазная бита"
power: 140
price: 12500
- id: 6
name: "Криптонитовая бита"
power: 160
price: 14500
- id: 7
name: "Буханка из пятёры"
power: 180
price: 16000
- id: 8
name: "Руки-базуки"
power: 200
price: 18000
- id: 9
name: "Какахи-торпеды"
power: 220
price: 20000
- id: 10
name: "Бита Бесконечности"
power: 250
price: 23000
- id: 11
name: "Бита 280"
power: 280
price: 25000

View File

@ -5,7 +5,9 @@ package datacache
import (
"errors"
"gopkg.in/yaml.v2"
"source.wtfteam.pro/i2_bot/i2_bot/lib/datamapping"
"source.wtfteam.pro/i2_bot/i2_bot/static"
"strconv"
)
@ -27,18 +29,17 @@ func (dc *DataCache) loadElements() {
func (dc *DataCache) getElements() []datamapping.Element {
elements := []datamapping.Element{}
elements = append(elements, datamapping.Element{1, "👊", "Боевой", 1})
elements = append(elements, datamapping.Element{2, "🌀", "Летающий", 1})
elements = append(elements, datamapping.Element{3, "💀", "Ядовитый", 1})
elements = append(elements, datamapping.Element{4, "🗿", "Каменный", 1})
elements = append(elements, datamapping.Element{5, "🔥", "Огненный", 2})
elements = append(elements, datamapping.Element{6, "⚡", "Электрический", 2})
elements = append(elements, datamapping.Element{7, "💧", "Водяной", 2})
elements = append(elements, datamapping.Element{8, "🍀", "Травяной", 2})
elements = append(elements, datamapping.Element{9, "💩", "Отважный", 3})
elements = append(elements, datamapping.Element{10, "👁", "Психический", 3})
elements = append(elements, datamapping.Element{11, "👿", "Тёмный", 3})
elements = append(elements, datamapping.Element{12, "⌛", "Времени", 3})
yamlFile, err := static.ReadFile("elements.yml")
if err != nil {
c.Log.Error(err.Error())
c.Log.Fatal("Can't read elements data file")
}
err = yaml.Unmarshal(yamlFile, &elements)
if err != nil {
c.Log.Error(err.Error())
c.Log.Fatal("Can't parse elements data file")
}
return elements
}

View File

@ -5,7 +5,9 @@ package datacache
import (
"errors"
"gopkg.in/yaml.v2"
"source.wtfteam.pro/i2_bot/i2_bot/lib/datamapping"
"source.wtfteam.pro/i2_bot/i2_bot/static"
"strconv"
)
@ -27,9 +29,17 @@ func (dc *DataCache) loadLeagues() {
func (dc *DataCache) getLeagues() []datamapping.League {
leagues := []datamapping.League{}
leagues = append(leagues, datamapping.League{1, "🈸", "ИНСТИНКТ"})
leagues = append(leagues, datamapping.League{2, "🈳 ", "МИСТИКА"})
leagues = append(leagues, datamapping.League{3, "🈵", "ОТВАГА"})
yamlFile, err := static.ReadFile("leagues.yml")
if err != nil {
c.Log.Error(err.Error())
c.Log.Fatal("Can't read leagues data file")
}
err = yaml.Unmarshal(yamlFile, &leagues)
if err != nil {
c.Log.Error(err.Error())
c.Log.Fatal("Can't parse leagues data file")
}
return leagues
}

View File

@ -5,7 +5,9 @@ package datacache
import (
"errors"
"gopkg.in/yaml.v2"
"source.wtfteam.pro/i2_bot/i2_bot/lib/datamapping"
"source.wtfteam.pro/i2_bot/i2_bot/static"
"strconv"
)
@ -27,12 +29,17 @@ func (dc *DataCache) loadLocations() {
func (dc *DataCache) getLocations() []datamapping.Location {
locations := []datamapping.Location{}
locations = append(locations, datamapping.Location{1, "🌲", "Лес"})
locations = append(locations, datamapping.Location{2, "⛰", "Горы"})
locations = append(locations, datamapping.Location{3, "🚣", "Озеро"})
locations = append(locations, datamapping.Location{4, "🏙", "Город"})
locations = append(locations, datamapping.Location{5, "🏛", "Катакомбы"})
locations = append(locations, datamapping.Location{6, "⛪️", "Кладбище"})
yamlFile, err := static.ReadFile("locations.yml")
if err != nil {
c.Log.Error(err.Error())
c.Log.Fatal("Can't read locations data file")
}
err = yaml.Unmarshal(yamlFile, &locations)
if err != nil {
c.Log.Error(err.Error())
c.Log.Fatal("Can't parse locations data file")
}
return locations
}

View File

@ -5,7 +5,9 @@ package datacache
import (
"errors"
"gopkg.in/yaml.v2"
"source.wtfteam.pro/i2_bot/i2_bot/lib/datamapping"
"source.wtfteam.pro/i2_bot/i2_bot/static"
"strconv"
"strings"
)
@ -28,13 +30,17 @@ func (dc *DataCache) loadWeapons() {
func (dc *DataCache) getWeapons() []datamapping.Weapon {
weapons := []datamapping.Weapon{}
weapons = append(weapons, datamapping.Weapon{1, "Бита", 2, 5})
weapons = append(weapons, datamapping.Weapon{2, "Стальная бита", 10, 40})
weapons = append(weapons, datamapping.Weapon{3, "Чугунная бита", 200, 500})
weapons = append(weapons, datamapping.Weapon{4, "Титановая бита", 2000, 10000})
weapons = append(weapons, datamapping.Weapon{5, "Алмазная бита", 10000, 100000})
weapons = append(weapons, datamapping.Weapon{6, "Криптонитовая бита", 100000, 500000})
weapons = append(weapons, datamapping.Weapon{7, "Буханка из пятёры", 1000000, 5000000})
yamlFile, err := static.ReadFile("weapons.yml")
if err != nil {
c.Log.Error(err.Error())
c.Log.Fatal("Can't read weapons data file")
}
err = yaml.Unmarshal(yamlFile, &weapons)
if err != nil {
c.Log.Error(err.Error())
c.Log.Fatal("Can't parse weapons data file")
}
return weapons
}

View File

@ -5,8 +5,8 @@ package datamapping
// Element is a struct, which represents element data
type Element struct {
ID int
Symbol string
Name string
LeagueID int
ID int `yaml:"id"`
Symbol string `yaml:"symbol"`
Name string `yaml:"name"`
LeagueID int `yaml:"league_id"`
}

View File

@ -5,7 +5,7 @@ package datamapping
// League is a struct, which represents league data
type League struct {
ID int
Symbol string
Name string
ID int `yaml:"id"`
Symbol string `yaml:"symbol"`
Name string `yaml:"name"`
}

View File

@ -5,7 +5,7 @@ package datamapping
// Location is a struct, which represents location data
type Location struct {
ID int
Symbol string
Name string
ID int `yaml:"id"`
Symbol string `yaml:"symbol"`
Name string `yaml:"name"`
}

View File

@ -5,8 +5,8 @@ package datamapping
// Weapon is a struct, which represents weapon data
type Weapon struct {
ID int
Name string
Power int
Price int
ID int `yaml:"id"`
Name string `yaml:"name"`
Power int `yaml:"power"`
Price int `yaml:"price"`
}

210
static/ab0x.go Normal file
View File

@ -0,0 +1,210 @@
// Code generated by fileb0x at "2018-04-30 19:42:29.945122063 +0400 +04 m=+0.004478925" from config file "b0x.yaml" DO NOT EDIT.
// modification hash(4eca41b6607bbac040da73b72d816cc7.81c8b21350256c12bfec846430631e9b)
package static
import (
"bytes"
"io"
"net/http"
"os"
"path"
"context"
"golang.org/x/net/webdav"
)
var (
// CTX is a context for webdav vfs
CTX = context.Background()
// FS is a virtual memory file system
FS = webdav.NewMemFS()
// Handler is used to server files through a http handler
Handler *webdav.Handler
// HTTP is the http file system
HTTP http.FileSystem = new(HTTPFS)
)
// HTTPFS implements http.FileSystem
type HTTPFS struct{}
// FileElementsYml is "elements.yml"
var FileElementsYml = []byte("\x2d\x20\x69\x64\x3a\x20\x31\x0a\x20\x20\x73\x79\x6d\x62\x6f\x6c\x3a\x20\x22\xf0\x9f\x91\x8a\x22\x0a\x20\x20\x6e\x61\x6d\x65\x3a\x20\x22\xd0\x91\xd0\xbe\xd0\xb5\xd0\xb2\xd0\xbe\xd0\xb9\x22\x0a\x20\x20\x6c\x65\x61\x67\x75\x65\x5f\x69\x64\x3a\x20\x31\x0a\x2d\x20\x69\x64\x3a\x20\x32\x0a\x20\x20\x73\x79\x6d\x62\x6f\x6c\x3a\x20\x22\xf0\x9f\x8c\x80\x22\x0a\x20\x20\x6e\x61\x6d\x65\x3a\x20\x22\xd0\x9b\xd0\xb5\xd1\x82\xd0\xb0\xd1\x8e\xd1\x89\xd0\xb8\xd0\xb9\x22\x0a\x20\x20\x6c\x65\x61\x67\x75\x65\x5f\x69\x64\x3a\x20\x31\x0a\x2d\x20\x69\x64\x3a\x20\x33\x0a\x20\x20\x73\x79\x6d\x62\x6f\x6c\x3a\x20\x22\xf0\x9f\x92\x80\x22\x0a\x20\x20\x6e\x61\x6d\x65\x3a\x20\x22\xd0\xaf\xd0\xb4\xd0\xbe\xd0\xb2\xd0\xb8\xd1\x82\xd1\x8b\xd0\xb9\x22\x0a\x20\x20\x6c\x65\x61\x67\x75\x65\x5f\x69\x64\x3a\x20\x31\x0a\x2d\x20\x69\x64\x3a\x20\x34\x0a\x20\x20\x73\x79\x6d\x62\x6f\x6c\x3a\x20\x22\xf0\x9f\x97\xbf\x22\x0a\x20\x20\x6e\x61\x6d\x65\x3a\x20\x22\xd0\x9a\xd0\xb0\xd0\xbc\xd0\xb5\xd0\xbd\xd0\xbd\xd1\x8b\xd0\xb9\x22\x0a\x20\x20\x6c\x65\x61\x67\x75\x65\x5f\x69\x64\x3a\x20\x31\x0a\x2d\x20\x69\x64\x3a\x20\x35\x0a\x20\x20\x73\x79\x6d\x62\x6f\x6c\x3a\x20\x22\xf0\x9f\x94\xa5\x22\x0a\x20\x20\x6e\x61\x6d\x65\x3a\x20\x22\xd0\x9e\xd0\xb3\xd0\xbd\xd0\xb5\xd0\xbd\xd0\xbd\xd1\x8b\xd0\xb9\x22\x0a\x20\x20\x6c\x65\x61\x67\x75\x65\x5f\x69\x64\x3a\x20\x32\x0a\x2d\x20\x69\x64\x3a\x20\x36\x0a\x20\x20\x73\x79\x6d\x62\x6f\x6c\x3a\x20\x22\xe2\x9a\xa1\x22\x0a\x20\x20\x6e\x61\x6d\x65\x3a\x20\x22\xd0\xad\xd0\xbb\xd0\xb5\xd0\xba\xd1\x82\xd1\x80\xd0\xb8\xd1\x87\xd0\xb5\xd1\x81\xd0\xba\xd0\xb8\xd0\xb9\x22\x0a\x20\x20\x6c\x65\x61\x67\x75\x65\x5f\x69\x64\x3a\x20\x32\x0a\x2d\x20\x69\x64\x3a\x20\x37\x0a\x20\x20\x73\x79\x6d\x62\x6f\x6c\x3a\x20\x22\xf0\x9f\x92\xa7\x22\x0a\x20\x20\x6e\x61\x6d\x65\x3a\x20\x22\xd0\x92\xd0\xbe\xd0\xb4\xd1\x8f\xd0\xbd\xd0\xbe\xd0\xb9\x22\x0a\x20\x20\x6c\x65\x61\x67\x75\x65\x5f\x69\x64\x3a\x20\x32\x0a\x2d\x20\x69\x64\x3a\x20\x38\x0a\x20\x20\x73\x79\x6d\x62\x6f\x6c\x3a\x20\x22\xf0\x9f\x8d\x80\x22\x0a\x20\x20\x6e\x61\x6d\x65\x3a\x20\x22\xd0\xa2\xd1\x80\xd0\xb0\xd0\xb2\xd1\x8f\xd0\xbd\xd0\xbe\xd0\xb9\x22\x0a\x20\x20\x6c\x65\x61\x67\x75\x65\x5f\x69\x64\x3a\x20\x32\x0a\x2d\x20\x69\x64\x3a\x20\x39\x0a\x20\x20\x73\x79\x6d\x62\x6f\x6c\x3a\x20\x22\xf0\x9f\x92\xa9\x22\x0a\x20\x20\x6e\x61\x6d\x65\x3a\x20\x22\xd0\x9e\xd1\x82\xd0\xb2\xd0\xb0\xd0\xb6\xd0\xbd\xd1\x8b\xd0\xb9\x22\x0a\x20\x20\x6c\x65\x61\x67\x75\x65\x5f\x69\x64\x3a\x20\x33\x0a\x2d\x20\x69\x64\x3a\x20\x31\x30\x0a\x20\x20\x73\x79\x6d\x62\x6f\x6c\x3a\x20\x22\xf0\x9f\x91\x81\x22\x0a\x20\x20\x6e\x61\x6d\x65\x3a\x20\x22\xd0\x9f\xd1\x81\xd0\xb8\xd1\x85\xd0\xb8\xd1\x87\xd0\xb5\xd1\x81\xd0\xba\xd0\xb8\xd0\xb9\x22\x0a\x20\x20\x6c\x65\x61\x67\x75\x65\x5f\x69\x64\x3a\x20\x33\x0a\x2d\x20\x69\x64\x3a\x20\x31\x31\x0a\x20\x20\x73\x79\x6d\x62\x6f\x6c\x3a\x20\x22\xf0\x9f\x91\xbf\x22\x0a\x20\x20\x6e\x61\x6d\x65\x3a\x20\x22\xd0\xa2\xd0\xb5\xd0\xbc\xd0\xbd\xd1\x8b\xd0\xb9\x22\x0a\x20\x20\x6c\x65\x61\x67\x75\x65\x5f\x69\x64\x3a\x20\x33\x0a\x2d\x20\x69\x64\x3a\x20\x31\x32\x0a\x20\x20\x73\x79\x6d\x62\x6f\x6c\x3a\x20\x22\xe2\x8c\x9b\x22\x0a\x20\x20\x6e\x61\x6d\x65\x3a\x20\x22\xd0\x92\xd1\x80\xd0\xb5\xd0\xbc\xd0\xb5\xd0\xbd\xd0\xb8\x22\x0a\x20\x20\x6c\x65\x61\x67\x75\x65\x5f\x69\x64\x3a\x20\x33")
// FileLeaguesYml is "leagues.yml"
var FileLeaguesYml = []byte("\x2d\x20\x69\x64\x3a\x20\x31\x0a\x20\x20\x73\x79\x6d\x62\x6f\x6c\x3a\x20\xf0\x9f\x88\xb8\x0a\x20\x20\x6e\x61\x6d\x65\x3a\x20\x22\xd0\x98\xd0\x9d\xd0\xa1\xd0\xa2\xd0\x98\xd0\x9d\xd0\x9a\xd0\xa2\x22\x0a\x2d\x20\x69\x64\x3a\x20\x32\x0a\x20\x20\x73\x79\x6d\x62\x6f\x6c\x3a\x20\xf0\x9f\x88\xb3\x0a\x20\x20\x6e\x61\x6d\x65\x3a\x20\x22\xd0\x9c\xd0\x98\xd0\xa1\xd0\xa2\xd0\x98\xd0\x9a\xd0\x90\x22\x0a\x2d\x20\x69\x64\x3a\x20\x33\x0a\x20\x20\x73\x79\x6d\x62\x6f\x6c\x3a\x20\xf0\x9f\x88\xb5\x0a\x20\x20\x6e\x61\x6d\x65\x3a\x20\x22\xd0\x9e\xd0\xa2\xd0\x92\xd0\x90\xd0\x93\xd0\x90\x22")
// FileLocationsYml is "locations.yml"
var FileLocationsYml = []byte("\x2d\x20\x69\x64\x3a\x20\x31\x0a\x20\x20\x73\x79\x6d\x62\x6f\x6c\x3a\x20\x22\xf0\x9f\x8c\xb2\x22\x0a\x20\x20\x6e\x61\x6d\x65\x3a\x20\x22\xd0\x9b\xd0\xb5\xd1\x81\x22\x0a\x2d\x20\x69\x64\x3a\x20\x32\x0a\x20\x20\x73\x79\x6d\x62\x6f\x6c\x3a\x20\x22\xe2\x9b\xb0\x22\x0a\x20\x20\x6e\x61\x6d\x65\x3a\x20\x22\xd0\x93\xd0\xbe\xd1\x80\xd1\x8b\x22\x0a\x2d\x20\x69\x64\x3a\x20\x33\x0a\x20\x20\x73\x79\x6d\x62\x6f\x6c\x3a\x20\x22\xf0\x9f\x9a\xa3\x22\x0a\x20\x20\x6e\x61\x6d\x65\x3a\x20\x22\xd0\x9e\xd0\xb7\xd0\xb5\xd1\x80\xd0\xbe\x22\x0a\x2d\x20\x69\x64\x3a\x20\x34\x0a\x20\x20\x73\x79\x6d\x62\x6f\x6c\x3a\x20\x22\xf0\x9f\x8f\x99\x22\x0a\x20\x20\x6e\x61\x6d\x65\x3a\x20\x22\xd0\x93\xd0\xbe\xd1\x80\xd0\xbe\xd0\xb4\x22\x0a\x2d\x20\x69\x64\x3a\x20\x35\x0a\x20\x20\x73\x79\x6d\x62\x6f\x6c\x3a\x20\x22\xf0\x9f\x8f\x9b\x22\x0a\x20\x20\x6e\x61\x6d\x65\x3a\x20\x22\xd0\x9a\xd0\xb0\xd1\x82\xd0\xb0\xd0\xba\xd0\xbe\xd0\xbc\xd0\xb1\xd1\x8b\x22\x0a\x2d\x20\x69\x64\x3a\x20\x36\x0a\x20\x20\x73\x79\x6d\x62\x6f\x6c\x3a\x20\x22\xe2\x9b\xaa\xef\xb8\x8f\x22\x0a\x20\x20\x6e\x61\x6d\x65\x3a\x20\x22\xd0\x9a\xd0\xbb\xd0\xb0\xd0\xb4\xd0\xb1\xd0\xb8\xd1\x89\xd0\xb5\x22")
// FileWeaponsYml is "weapons.yml"
var FileWeaponsYml = []byte("\x2d\x20\x69\x64\x3a\x20\x31\x0a\x20\x20\x6e\x61\x6d\x65\x3a\x20\x22\xd0\x91\xd0\xb8\xd1\x82\xd0\xb0\x22\x0a\x20\x20\x70\x6f\x77\x65\x72\x3a\x20\x33\x0a\x20\x20\x70\x72\x69\x63\x65\x3a\x20\x35\x0a\x2d\x20\x69\x64\x3a\x20\x32\x0a\x20\x20\x6e\x61\x6d\x65\x3a\x20\x22\xd0\xa1\xd1\x82\xd0\xb0\xd0\xbb\xd1\x8c\xd0\xbd\xd0\xb0\xd1\x8f\x20\xd0\xb1\xd0\xb8\xd1\x82\xd0\xb0\x22\x0a\x20\x20\x70\x6f\x77\x65\x72\x3a\x20\x33\x30\x0a\x20\x20\x70\x72\x69\x63\x65\x3a\x20\x32\x37\x30\x30\x0a\x2d\x20\x69\x64\x3a\x20\x33\x0a\x20\x20\x6e\x61\x6d\x65\x3a\x20\x22\xd0\xa7\xd1\x83\xd0\xb3\xd1\x83\xd0\xbd\xd0\xbd\xd0\xb0\xd1\x8f\x20\xd0\xb1\xd0\xb8\xd1\x82\xd0\xb0\x22\x0a\x20\x20\x70\x6f\x77\x65\x72\x3a\x20\x36\x30\x0a\x20\x20\x70\x72\x69\x63\x65\x3a\x20\x35\x34\x30\x30\x0a\x2d\x20\x69\x64\x3a\x20\x34\x0a\x20\x20\x6e\x61\x6d\x65\x3a\x20\x22\xd0\xa2\xd0\xb8\xd1\x82\xd0\xb0\xd0\xbd\xd0\xbe\xd0\xb2\xd0\xb0\xd1\x8f\x20\xd0\xb1\xd0\xb8\xd1\x82\xd0\xb0\x22\x0a\x20\x20\x70\x6f\x77\x65\x72\x3a\x20\x31\x30\x30\x0a\x20\x20\x70\x72\x69\x63\x65\x3a\x20\x39\x30\x30\x30\x0a\x2d\x20\x69\x64\x3a\x20\x35\x0a\x20\x20\x6e\x61\x6d\x65\x3a\x20\x22\xd0\x90\xd0\xbb\xd0\xbc\xd0\xb0\xd0\xb7\xd0\xbd\xd0\xb0\xd1\x8f\x20\xd0\xb1\xd0\xb8\xd1\x82\xd0\xb0\x22\x0a\x20\x20\x70\x6f\x77\x65\x72\x3a\x20\x31\x34\x30\x0a\x20\x20\x70\x72\x69\x63\x65\x3a\x20\x31\x32\x35\x30\x30\x0a\x2d\x20\x69\x64\x3a\x20\x36\x0a\x20\x20\x6e\x61\x6d\x65\x3a\x20\x22\xd0\x9a\xd1\x80\xd0\xb8\xd0\xbf\xd1\x82\xd0\xbe\xd0\xbd\xd0\xb8\xd1\x82\xd0\xbe\xd0\xb2\xd0\xb0\xd1\x8f\x20\xd0\xb1\xd0\xb8\xd1\x82\xd0\xb0\x22\x0a\x20\x20\x70\x6f\x77\x65\x72\x3a\x20\x31\x36\x30\x0a\x20\x20\x70\x72\x69\x63\x65\x3a\x20\x31\x34\x35\x30\x30\x0a\x2d\x20\x69\x64\x3a\x20\x37\x0a\x20\x20\x6e\x61\x6d\x65\x3a\x20\x22\xd0\x91\xd1\x83\xd1\x85\xd0\xb0\xd0\xbd\xd0\xba\xd0\xb0\x20\xd0\xb8\xd0\xb7\x20\xd0\xbf\xd1\x8f\xd1\x82\xd1\x91\xd1\x80\xd1\x8b\x22\x0a\x20\x20\x70\x6f\x77\x65\x72\x3a\x20\x31\x38\x30\x0a\x20\x20\x70\x72\x69\x63\x65\x3a\x20\x31\x36\x30\x30\x30\x0a\x2d\x20\x69\x64\x3a\x20\x38\x0a\x20\x20\x6e\x61\x6d\x65\x3a\x20\x22\xd0\xa0\xd1\x83\xd0\xba\xd0\xb8\x2d\xd0\xb1\xd0\xb0\xd0\xb7\xd1\x83\xd0\xba\xd0\xb8\x22\x0a\x20\x20\x70\x6f\x77\x65\x72\x3a\x20\x32\x30\x30\x0a\x20\x20\x70\x72\x69\x63\x65\x3a\x20\x31\x38\x30\x30\x30\x0a\x2d\x20\x69\x64\x3a\x20\x39\x0a\x20\x20\x6e\x61\x6d\x65\x3a\x20\x22\xd0\x9a\xd0\xb0\xd0\xba\xd0\xb0\xd1\x85\xd0\xb8\x2d\xd1\x82\xd0\xbe\xd1\x80\xd0\xbf\xd0\xb5\xd0\xb4\xd1\x8b\x22\x0a\x20\x20\x70\x6f\x77\x65\x72\x3a\x20\x32\x32\x30\x0a\x20\x20\x70\x72\x69\x63\x65\x3a\x20\x32\x30\x30\x30\x30\x0a\x2d\x20\x69\x64\x3a\x20\x31\x30\x0a\x20\x20\x6e\x61\x6d\x65\x3a\x20\x22\xd0\x91\xd0\xb8\xd1\x82\xd0\xb0\x20\xd0\x91\xd0\xb5\xd1\x81\xd0\xba\xd0\xbe\xd0\xbd\xd0\xb5\xd1\x87\xd0\xbd\xd0\xbe\xd1\x81\xd1\x82\xd0\xb8\x22\x0a\x20\x20\x70\x6f\x77\x65\x72\x3a\x20\x32\x35\x30\x0a\x20\x20\x70\x72\x69\x63\x65\x3a\x20\x32\x33\x30\x30\x30\x0a\x2d\x20\x69\x64\x3a\x20\x31\x31\x0a\x20\x20\x6e\x61\x6d\x65\x3a\x20\x22\xd0\x91\xd0\xb8\xd1\x82\xd0\xb0\x20\x32\x38\x30\x22\x0a\x20\x20\x70\x6f\x77\x65\x72\x3a\x20\x32\x38\x30\x0a\x20\x20\x70\x72\x69\x63\x65\x3a\x20\x32\x35\x30\x30\x30")
func init() {
if CTX.Err() != nil {
panic(CTX.Err())
}
var err error
var f webdav.File
f, err = FS.OpenFile(CTX, "elements.yml", os.O_RDWR|os.O_CREATE|os.O_TRUNC, 0777)
if err != nil {
panic(err)
}
_, err = f.Write(FileElementsYml)
if err != nil {
panic(err)
}
err = f.Close()
if err != nil {
panic(err)
}
f, err = FS.OpenFile(CTX, "leagues.yml", os.O_RDWR|os.O_CREATE|os.O_TRUNC, 0777)
if err != nil {
panic(err)
}
_, err = f.Write(FileLeaguesYml)
if err != nil {
panic(err)
}
err = f.Close()
if err != nil {
panic(err)
}
f, err = FS.OpenFile(CTX, "locations.yml", os.O_RDWR|os.O_CREATE|os.O_TRUNC, 0777)
if err != nil {
panic(err)
}
_, err = f.Write(FileLocationsYml)
if err != nil {
panic(err)
}
err = f.Close()
if err != nil {
panic(err)
}
f, err = FS.OpenFile(CTX, "weapons.yml", os.O_RDWR|os.O_CREATE|os.O_TRUNC, 0777)
if err != nil {
panic(err)
}
_, err = f.Write(FileWeaponsYml)
if err != nil {
panic(err)
}
err = f.Close()
if err != nil {
panic(err)
}
Handler = &webdav.Handler{
FileSystem: FS,
LockSystem: webdav.NewMemLS(),
}
}
// Open a file
func (hfs *HTTPFS) Open(path string) (http.File, error) {
f, err := FS.OpenFile(CTX, path, os.O_RDONLY, 0644)
if err != nil {
return nil, err
}
return f, nil
}
// ReadFile is adapTed from ioutil
func ReadFile(path string) ([]byte, error) {
f, err := FS.OpenFile(CTX, path, os.O_RDONLY, 0644)
if err != nil {
return nil, err
}
buf := bytes.NewBuffer(make([]byte, 0, bytes.MinRead))
// If the buffer overflows, we will get bytes.ErrTooLarge.
// Return that as an error. Any other panic remains.
defer func() {
e := recover()
if e == nil {
return
}
if panicErr, ok := e.(error); ok && panicErr == bytes.ErrTooLarge {
err = panicErr
} else {
panic(e)
}
}()
_, err = buf.ReadFrom(f)
return buf.Bytes(), err
}
// WriteFile is adapTed from ioutil
func WriteFile(filename string, data []byte, perm os.FileMode) error {
f, err := FS.OpenFile(CTX, filename, os.O_WRONLY|os.O_CREATE|os.O_TRUNC, perm)
if err != nil {
return err
}
n, err := f.Write(data)
if err == nil && n < len(data) {
err = io.ErrShortWrite
}
if err1 := f.Close(); err == nil {
err = err1
}
return err
}
// WalkDirs looks for files in the given dir and returns a list of files in it
// usage for all files in the b0x: WalkDirs("", false)
func WalkDirs(name string, includeDirsInList bool, files ...string) ([]string, error) {
f, err := FS.OpenFile(CTX, name, os.O_RDONLY, 0)
if err != nil {
return nil, err
}
fileInfos, err := f.Readdir(0)
if err != nil {
return nil, err
}
err = f.Close()
if err != nil {
return nil, err
}
for _, info := range fileInfos {
filename := path.Join(name, info.Name())
if includeDirsInList || !info.IsDir() {
files = append(files, filename)
}
if info.IsDir() {
files, err = WalkDirs(filename, includeDirsInList, files...)
if err != nil {
return nil, err
}
}
}
return files, nil
}