Skip to content

Instantly share code, notes, and snippets.

View LuizMoratelli's full-sized avatar

Luiz Augusto Moratelli LuizMoratelli

View GitHub Profile
@LuizMoratelli
LuizMoratelli / TextEnhanceData.cs
Last active March 28, 2024 19:55
[TCG Engine] Enhance Text at Preview
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
using Sirenix.OdinInspector;
using System.Text.RegularExpressions;
namespace TcgEngine
{
[InlineButton("@CardEditor.CloneAction($root, $property, $value)", SdfIconType.FileEarmarkPlusFill, "", ShowIf = "@CardEditor.ShowNotNull($value)")]
[CreateAssetMenu(fileName = "textEnhancer", menuName = "TcgEngine/TextEnhancer", order = 99)]
@LuizMoratelli
LuizMoratelli / AILogic.cs
Last active March 26, 2024 13:02
[TcgEngine] Custom Mana System
private void CalculateNode(Game data, NodeState node)
{
//...
bool is_full_mana = HasAction(action_list, GameAction.PlayCard) && player.ManaMax() >= player.Mana();
//...
}
@LuizMoratelli
LuizMoratelli / tcg-engine-meets-odin.md
Last active March 19, 2024 22:19
[TCG Engine] 🤝 [Odin]

1 Adding Attributes to Data classes

1.1 CardData.cs

  [HorizontalGroup("Info", Width = 325)]
  [VerticalGroup("Info/Side1", Order =2), LabelWidth(50)]
  public string id;

  [VerticalGroup("Info/Side1"), LabelWidth(50)]
  public string title;
  [VerticalGroup("Info/Side2"), PreviewField(100), HideLabel,]
@LuizMoratelli
LuizMoratelli / create_so_and_attach.md
Created March 12, 2024 01:18
[Odin] Create a button to create and add reference to new SO

Simple and easy way to add a new button for create and attach an SO to another, this make easier to create abilities for cards in my game (removing the need of create the SO, find the card, and attach)

Result: image

In Editor.cs

public class MyDataProcessor : OdinAttributeProcessor<MyData>
{
@LuizMoratelli
LuizMoratelli / start-of-game.md
Last active December 11, 2023 07:42
[TCG Engine] Create Start of Game Effects

1. Create a new AbilityTrigger "StartOfGame" in AbilityData.cs

public enum AbilityTrigger {
  //...
  StartOfGame = 19, // On-time
  //...
}

2. Update GameLogic.cs to resolve "StartOfGame" Abilities before the 1st turn begins.

@LuizMoratelli
LuizMoratelli / gist:dbc73ab9890b28e188aa6f81e16f74bb
Created August 16, 2023 13:19
AbilityMod_OnFullCombo_TwoVulnerable.json
{
"$type": "UAssetAPI.UAsset, UAssetAPI",
"Info": "Serialized with UAssetAPI 1.0.0.0 (a5978d9)",
"NameMap": [
"/Game/Coda/Templates/AbilityKeywords/Card/Keyword_FullCombo",
"/Game/Coda/Templates/AbilityKeywords/Card/Keyword_FullCombo.Keyword_FullCombo",
"/Game/Coda/Templates/AbilityKeywords/StatusEffects/Keyword_Vulnerable",
"/Game/Coda/Templates/AbilityKeywords/StatusEffects/Keyword_Vulnerable.Keyword_Vulnerable",
"/Game/Coda/Templates/Effects/Effect_Vulnerable",
"/Game/Coda/Templates/Effects/Effect_Vulnerable.Effect_Vulnerable",
@LuizMoratelli
LuizMoratelli / Explosive_Shot.md
Last active August 6, 2023 07:06
[TCG Engine] Imitating Hearthstone cards and learning in the process

Explosive Shot (Classic)

Description

(5) "Deal 5 damage to a minion and 2 damage to adjacent ones."

Steps

  1. Create a new Ability with "Damage" effect, "value" equals 5.
    image
export const isSubset = <T extends { id: string }>(array: T[], subset: T[]): boolean => {
const ids: string[] = array.map((item: T) => item.id);
const notInArray = subset.filter((item: T) => !ids.includes(item.id))
return notInArray.length <= 0;
}
// @fakenickles
@LuizMoratelli
LuizMoratelli / chosen.jquery.js
Last active August 19, 2019 18:30
Chosen 1.8.2 hanoii upgraded to support accented letters like hanoii's chosen 1.4.2. Chosen 1.8.2 hanoii atualizado para suportar letras acentuadas, assim como a versão 1.4.2.
/*!
Chosen, a Select Box Enhancer for jQuery and Prototype
by Patrick Filler for Harvest, http://getharvest.com
Version 1.8.2-hanoii
Full source at https://github.com/harvesthq/chosen
Copyright (c) 2011-2017 Harvest http://getharvest.com
MIT License, https://github.com/harvesthq/chosen/blob/master/LICENSE.md
This file is generated by `grunt build`, do not edit it by hand.
@LuizMoratelli
LuizMoratelli / retornarResultadosAleatorios.php
Last active May 17, 2019 13:08
Laravel: como retornar resultados aleatórios do banco de dados
<?php
/**
* Exemplo de uso: retornar determinado número de produtos em destaque para apresentar na web.
* Considerando um model Produto com um atributo em_destaque: 1 = SIM | 2 = NÃO
*/
/**
* 1. Retornar os produtos do banco de dados.
*/
$produtos = Produto::all();